Let say when user click a button that has caption Blue, I need to color all cells selected on the grid with blue color. If the green color button is click, I need to color all selected cells with green background. How can I call or trigger itemFormatter? can I write a seperate function and call it when a button on my form is click? This is what I have tried:
I am checking for cells with matching code, then color it background with the color pass in from the color button selector:
for (let r = 0; r < this.flex.rows.length - 1; r++) {
for (let c = this.firstDate; c < this.flex.columns.length - 1; c++) {
if (code === this.flex.getCellData(r, c, false)) {
let cellElement = this.flex.cells.getCellElement(r, c);
if (!Library.isNullOrUndefined(cellElement)) {
cellElement.style.background = color;
}
}
}
}
this.flex.invalidate();
This will work, except when I scroll the the flexgrid vertically or horizontally, the color cells now color to other cells.
Example, I range(25, 1, 27, 3) are matching with the code I am looking for, the background of these cell will be colored with my new color. But if I scroll the grid vertically, now range(25, 1, 27, 3) will be moving downward. the position where range(25, 1, 27, 3) moved downward now occupy by some other cells that were above range(25, 1, 27, 3) . Now range(25, 1, 27, 3) loose all color (back to the original color) and new cells that occupy the position of range(25, 1, 27, 3) get color with new color. It look to me that the color remain in the same coordinate, while cell data are moving upward/downward with mouse scrolling. Is there another way to achieve cell coloring without using itemFormatter fot formatItem. I am tring to improve performance of my app. Thank yo sir very much.