Premium support for our pure JavaScript UI components


Post by kevin.snps »

Hi Bryntum , We have a feature where the rows should be colored alternatively . so for this we implemented a custom class which is similar to stripe(feature) but with our business logic.

the below line of code doesn't seem to return all of the rows.

const rows = await grid.rowManager.rows;

the whole code

export default (base) =>
  class CombineStripe extends base {
    static get $name() {
      return 'combineStripe';
    }

async construct(grid, config) {
  super.construct(grid, config);
  // adds the colors to the rows
  await this.addColorToRows(grid);
}

doDisable(disable) {
  if (!this.isConfiguring) {
    // Refresh rows to add/remove even/odd classes
    this.client.refreshRows();
  }

  super.doDisable(disable);
}

/** add colors to 2 rows alternatively */
async addColorToRows(grid) {
  const rows = await grid.rowManager.rows;

  const mainObjectMap = new Map();
  let isColor = true;

  console.log(rows);
  for(let row of rows) {
    const mo = row.cellContext._record._data.mainObject;
    if(mainObjectMap.get(mo) === undefined) {
      mainObjectMap.set(mo, []);
    }

    mainObjectMap.get(mo).push(row);
  }

  mainObjectMap.forEach((values,key) => {
    if(key !== undefined) {
      for(let row of values) {

        row.assignCls({
          'b-add-color-row': !isColor,
        })
      }
    }

    isColor = !isColor;
  });
}
  };
  

we have upto 10 resources .

image (1).png
image (1).png (162.68 KiB) Viewed 202 times

but when i try to get the rows by doing
await grid.rowManager.rows I can only get until RO-000007

image (2).png
image (2).png (181.79 KiB) Viewed 202 times

due to this reason there seems to be bug that occurs when our custom code is ran. Could you please tell us why this is happening .Thank you.


Post by alex.l »

RowManager is a private class and shouldn't be used.
You see not all rows because not all rows has been rendered at once, we add onto DOM only required structures, so it may contain rows for visible area with some buffer.

https://bryntum.com/docs/gantt/api/Grid/column/Column#config-renderer has row in params that may be used for your purposes.

All the best,
Alex


Post by kevin.snps »

Hi Alex, thank you for the reply.
Thank you for informing us about Grid.column.Column#config-renderer. We have tried this, and got what we have desired.


Post Reply