List grid slow on cell refresh

Hi, I have external custom css, that overrides the the one from the sc.
I call this method:

private void overCell(final int rowNum, final int colNum) {
                if (overCell[rowNum][colNum])
                        return;
                overCell[rowNum][colNum] = true;
                refreshCell(rowNum, colNum);
        }

@Override
        protected String getCellCSSText(final ListGridRecord record, final int rowNum, final int colNum) {
                if (overCell[rowNum][colNum])
                        return cellOverStyle((SurfaceRecord) record, rowNum, colNum);
                return cellBaseStyle((SurfaceRecord) record, rowNum, colNum);
        }

Any ideas why the rendering is slow?

Because for every new cell being rendered, getCellCssText is being called, and you are calling refreshCell on the old cell. Why would you do that?

Well my college does this. But i think that there are 3 types of cells and they must be in different colors, so when point to some cell the color must be changed (mark) and he implemented selection of subgrid like the selection in cubegrid or simulating excel grid. And the cell must be always re-rendered

Have you tried running your code without calling refreshCell?

Sanjiv

Well we are trying to create sub grid selection like the one in cube grid in smart client, every thing works fine, except that the cell unmarking is slow. Also we want some cells that match our criteria to be rendered in custom colors, and when selected (marked) to become with other color. That is why we need to call refreshCell method.

We fixed the problem. We user refreshCellStyle(..) that refreshes only the css not the text. We also need to change the text but this will be done in other event handler that is not mixed with the marking one.

Well - if the refresh cell method is not called - there is not way to “tell” the cell that a new style should be applied. With the default implementation of the ListGrid - CSS styles are used. These styles are applied for the entire row, not individual cells.
What I’m trying to achieve is the same behavior as the default one, but for cells instead. So the main question is - Is there a way to apply the CellBaseStyle to individual cell? This will speed things up for most of the implemented functionality.
Of course - I can override the getBaseStyle method of the ListGrid (and I already did that during my first attempt) to return different base style for each type of cell, but then - new problems arise: the styles are “fighting” each other. And again - rendering is slow

My bad… refreshCellStyle() does the job perfectly. Combined with the refreshCell() when values need to be updated as well - everything is much better now.

Just to clarify this thread - there would never be a valid reason to call either refreshCell() or refreshCellStyle() from getCellCSSText() because if getCellCSSText() is being called then that cell is already in the middle of being refreshed.

However it does make sense to call refreshCell()/refreshCellStyle() from within event handling logic such as a recordClick or mouseDown event, in order to update the appearance of cells.

I’ve managed to locate the cause of the slow unmarking/marking of cells my colleague mentioned a few posts up.

Imagine that the user quickly selects a subregion of cells. During the selection, some of the cells inside the region do not receive the MouseOver event. During the MouseUp (or the next MouseOver) event - all the unmarked cells are to be refreshed. If the region is large - refreshing happens very slowly.
Could the cause of these event “jumps” be the processing of the refreshCellStyle() method? Or event better question - does the event processing wait for the handler method to complete, before firing up another event?

Didn’t really follow the question, but we can tell you that the very fast drag selection built into the cube is careful to be incremental, only refreshing cells that require it.

The answers so far are about as much help as we can give for re-implementing a feature that already exists. Best of luck.

There was a minor bug, that caused the selection method to check if there were areas to deselect even if there were not (when expanding the selection area for example). The implementation is now finished.

Thanks a lot for the help