I'm using a virtual grid for displaying some data. Occasionally I hide some columns, however I still get QueryCellInfo events for the cells in those columns. Is this behaviour correct? If so, what can I do to prevent the unnecessary querying of my data (whats the best way to tell if a cell is visible)?
ADAdministrator Syncfusion Team April 1, 2003 05:47 AM
> I'm using a virtual grid for displaying some data. Occasionally I hide some columns, however I still get QueryCellInfo events for the cells in those columns. Is this behaviour correct? If so, what can I do to prevent the unnecessary querying of my data (whats the best way to tell if a cell is visible)?
This behavior is by design. You can check (colIndex >= 0 && grid.Model.HideCols[colIndex])in you QueryCellInfo event handler.
If this statement is true the associated column is hidden.
ADAdministrator Syncfusion Team June 20, 2003 03:45 AM
"By design" is OK, but what to do in case of huge virtual grid?
Although my event handlers don't do anything at all, 10000 QueryCellInfo's and PrepareViewStyleInfo's are dramatically slow.
I need to have a huge grid, but display only a small portion of info at a time. I hide 99% of cells, but still get QueryCellInfo's and PrepareViewStyleInfo's for them.
Is there any workaround?
ADAdministrator Syncfusion Team June 20, 2003 04:39 AM
So, you are dynamically hiding/unhiding major portions of your data source?
How about adding an arraylist that holds the indexes of the rows from your datasouce that you want visible. Then in QueryRowCount, provide the count from this ArrayList as the number of rows. Then in your QueryCellInfo handler, instead of using e.RowIndex to pick out the values from your datasource, use arralist1[e.RowIndex] to pick out the values.
In this manner, the grid will only ever have as many rows are you want visible. You would hide/unhide rows by adding and removing values from the array list. When you add/remove hidden rows, also call grid.ResetVolatileData so the QueryRowCount will provide the new count.
The VirtTreeGrid sample uses such a technique to only show the open rows. The VirtTreeGrif may have 1000 different nodes, but only 5 may be visible. Instead of hiding and showing rows to do this, it adjusts a visible row arraylist.
ADAdministrator Syncfusion Team June 20, 2003 05:39 AM
>So, you are dynamically hiding/unhiding major portions of your data source?
Yes. I have a huge 2D array of values. The user can select a rectangular area to be shown in the grid. To show this area in the grid, I hide the columns and rows on the left/right and on the top/bottom of the selected area.
The problem with your solution is that we need to maintain references in formulas. The user is able to enter formulas in the grid. Therefore, we need to maitain the relations between the grid and my data array. I.e. [0,0] of my array should always correspond to A1, etc. In the solution you propose, A1 will correspond to the top-left corner of the selection, which will break the formulas.
I've just installed v.184.108.40.206.
It's partially fixed the problem: Grid now fires QueryCellInfo and PrepareViewStyleInfo only for hidden columns _right_ and rows _down_ to my selection area, and doesn't do this for left columns and top rows.
Could you please make one more step?;-)
ADAdministrator Syncfusion Team June 20, 2003 06:25 AM
If the formulas you are adding are just TextBox cells and not FormulaCell cells, then you might want to consider using the earlier suggestion as you can handle the headers not being synced with your big table. If you are trying to use FormulaCell cells, then the dynamic grid idea will not work.
Since you are only handling a contiguous collection of rows and columns, you would not really need an arraylist. All you would need is the top-left indexes into your big table, and the number of visible rows and columns. To handle the problem of the row/column headers being out of sync, in your QueryCellInfo, you can just provide the proper values for e.Style.Text when e.ColIndex is zero and e.RowIndex is a particular. You can use GridRangeInfo.GetAlphaLabel to handle the columns just passing e.ColIndex+theLeftColIndexFromYourTable.