Posted 14 September 2017, 2:27 am EST
Hi Raunak,
Here are the 2 requirements I am trying to achieve:
-
I need to display custom HTML in multiple columns without the grid becoming too slow. There may be tens of thousands of items populating the grid.
-
One of the columns in my grid needs to be a menu of some sort. The menu options will be predefined and represent actions which can be performed in my application, in the context of the item populating the row.
Eg: If a row represents a device on a network, the menu might have an option to view a web page hosted at the device IP address.
Problems achieving requirement #1:
Scrolling performance of the grid deteriorates very noticeably when using itemFormatter. Even appending simple elements containing only text causes noticeable slowdown when scrolling the grid. Some testing shows that the performance issue may be caused by excessive re-rendering of cells when the grid is scrolled.
I thought that I could make re-renders faster by caching the HTML nodes that my itemFormatter appends into the cells, so that they could be recycled the next time itemFormatter is called. This did not improve performance very much (if at all) and instead caused the bug which can be seen in video I attached earlier.
After fighting to find out what caused that bug I came to the conclusion that the way in which FlexGrid recycles cell elements while scrolling is either buggy/unreliable or just unpredictable. I came to this conclusion after my itemFormatter added an HTML attribute to cells of a specific column and I found that HTML attribute on cells in other columns after scrolling the grid. I guess FlexGrid recycles cell elements, but they may be used in different places (different rows/colss) which means that setting attributes on cells will only cause problems. I really hope this is just a bug.
Knowing that cell elements might be recycled to different rows/cols, it could explain the appearance of excessive re-rendering (it may not be excessive, it may be that the cell element I was watching simply moved around to different rows/cols to remain always-in-view, and was being re-rendered with the contents of the new row/col). None of this is documented, so I don’t know how it works, or what is safe, not safe, or recommended.
Problems achieving requirement #2:
When scrolling the grid my itemFormatter is called multiple times on the same cell which means that the Menu (or ComboBox) is recreated multiple times for every cell, but wijmo thows an error stating that the cell is already hosting a control. Your example does this, too, and I’ve attached a video of it happening there.
There’s also an issue of CSS styling menus/comboboxes in cells (they don’t look right). In my application I cannot click the menu items unless it’s a menu that is in the very last row where the items appear below the grid (it may be my own bug with z-indexing).
2015/12/itemFormatterBug2.wmv