We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Row Selection moves CurrentCell to disabled column in DBG

I have a databound grid, and set Style.Enabled to false (as well as ReadOnly=true, Clickable=false) in PrepareViewStyleInfo for the leftmost three columns. The result is that user cannot activate, click or edit the cells in the first three columns by clicking on them directly, or tabbing across the cells which is exactly the desired effect. However when user selects a grid row by clicking a rowheader column, the cell that gets automatically activated is in the leftmost column, something that I thought was made impossible by my PrepareViewStyleInfo code. For me the correct behavior would be to make the cell in fourth column active (or have no active cell at all) What would be the correct way to achieve the desired behavior? Thanks, Gene

5 Replies

AD Administrator Syncfusion Team October 9, 2003 06:00 PM UTC

Try overriding QueryCellInfo instead when setting cells read-only, disabling them etc. The reason I suggest this is that PrepareViewStyleInfo is only called just before the cell gets drawn - It's main focus is to alter visual aspects of the grid and can take view state into consideration (like position of current cell, selected cells etc.) The style is only while a cell is drawn and will immediately discarded afterwards. QueryCellInfo on the other side is being called a bit earlier. It is meant to handle the state of cells. It's state is cached in the grid and it is not meant to handle view-specific context. If that does not work. Did you override any events, e.g CurrentCellMoving and/or CurrentCellActivating? Stefan


GG Gene Gorokhovsky October 10, 2003 10:06 AM UTC

Same behavior is observed when I set the styles of the first three columns at the grid initialization tyme (i.e. when GridBoundColumns are created), and do not manipulate them dynamically. I do not override any CurrentCell* events. Gene > Try overriding QueryCellInfo instead when setting cells read-only, disabling them etc. > > The reason I suggest this is that PrepareViewStyleInfo is only called just before the cell gets drawn - It's main focus is to alter visual aspects of the grid and can take view state into consideration (like position of current cell, selected cells etc.) The style is only while a cell is drawn and will immediately discarded afterwards. > > QueryCellInfo on the other side is being called a bit earlier. It is meant to handle the state of cells. It's state is cached in the grid and it is not meant to handle view-specific context. > > If that does not work. Did you override any events, e.g CurrentCellMoving and/or CurrentCellActivating? > > Stefan >


AD Administrator Syncfusion Team October 10, 2003 11:52 AM UTC

It's the CurrentCellActivating method in GridDataBoundGrid. It calls AdjustRowHeader and after that there are no more checks if the cell is enabled or not. So, try to override protected override void AdjustRowHeader(GridCurrentCellMovingEventArgs e) { if (e.ColIndex <= 0) e.ColIndex = 3; //Model.Cols.HeaderCount+1; } Stefan


GG Gene Gorokhovsky October 10, 2003 02:28 PM UTC

I feel that this is behavior that should be adjusted in the GridDataBoundGrid itself. Do you think this will make as an enhancement/bug fix? I have made a bit more generic using the following code: protected override void AdjustRowHeader(GridCurrentCellMovingEventArgs e) { if (e.ColIndex <=0) { e.ColIndex = FindFirstEnabledColumn(); } } private int FindFirstEnabledColumn() { if (this.GridBoundColumns != null) { for (int i = 0;i < this.GridBoundColumns.Count;i++) { if (this.GridBoundColumns[i].StyleInfo.Enabled) { return i + 1 + this.Model.Cols.HeaderCount; } } } return -1; } Perhaps this could be done better to take into account unbound columns etc. Gene > It's the CurrentCellActivating method in GridDataBoundGrid. It calls AdjustRowHeader and after that there are no more checks if the cell is enabled or not. > > So, try to override > > protected override void AdjustRowHeader(GridCurrentCellMovingEventArgs e) > { > if (e.ColIndex <= 0) > e.ColIndex = 3; //Model.Cols.HeaderCount+1; > } > > > Stefan >


AD Administrator Syncfusion Team October 10, 2003 03:05 PM UTC

We'll have that fixed in 1.6.1.8 and 2.0 Stefan

Loader.
Up arrow icon