I''m having a strange problem in my grid that may have been around for a while, but I''ve just noticed it and I''m really confused.
My grid is virtual. We have about 9 or 10 custom cell types and all of them appear to be operating properly, except for one which happens to be our TextBox control.
In the PrepareViewStyleInfo, I set the CellType for a group of cells to "MyTextBox".
I''ve already added the MyTextBox to the grid''s CellModels and the constructor for our custom model is being called.
Here''s where it gets weird. It''s clear that our renderer, associated with our TextBox is being used because if I make changes to the renderer, those changes appear in the cell.
For example, if cell [2,2] is set to "MyTextBox" in PrepareViewStyleInfo(), if I check the GridStyleInfo at [2,2], it reports the CellType as "TextBox" which is the default and the model associated with the StyleInfo is the Syncfusion TextBox model, not our model. But clearly our renderer is being used. It doesn''t matter when I check the GridStyleInfo for the cell, it always returns the "TextBox".
The problem is that we call ResizeToFit() against the column and the OnQueryPreferredClientSize() for our TextBox model isn''t being called. That''s how I discovered the problem. So I can''t set the column width properly because it''s not using our model. What I can''t figure out is how it could be using our renderer but not our model.
Any ideas? Is it possible it''s somehow getting reverted to the default?
ADAdministrator Syncfusion Team June 20, 2005 02:59 PM
PrepareViewStyleInfo happens late in the drawing process and may not happen at all in some other situtations where a cell style is needed (like resizing). For example, if you want to set a cell to be readOnly using a style, then you cannot set this in PrepareViewStyleInfo. It must be set in QueryCellInfo so the ReadOnly property is set before it is used.
So, you might try moving the code that sets the CellType down into QueryCellInfo.
ADAdministrator Syncfusion Team June 20, 2005 04:17 PM
That makes sense.
I guess that is an area of some confusion. Is there documentation, or could documentation be produced that specifies which things should be handled in PrepareViewStyleInfo and which should be handled in QueryCellInfo?
It seems clear that certain GridStyleInfo properties need to be set in one or the other and for some properties, it doesn''t seem to matter. For other''s, like this one, it''s a bit unclear.
ADAdministrator Syncfusion Team June 20, 2005 05:51 PM
Here are a couple of KB links.
ADAdministrator Syncfusion Team June 21, 2005 09:21 AM
Thanks, the first was very helpful. The second one was about making read only cells in DataBound grids...
But the first does answer a lot of questions for me. Thanks.