I am displaying 3 checkboxes for each record in a grouped grid and have cancelled the sort column functionality of the grid (i.e. grid.TableOptions.AllowSortColumns = false;).
But after I click on a checkbox, the records are re-ordered and shift position. This can be very annoying, especially if there is a lot of records.
Is there any way I can switch this off??
ADAdministrator Syncfusion Team September 15, 2004 07:00 AM
Did you add any fields to the SortColumns collection?
Or is the underlying datasource sorted by these fields?
The reason I am asking is because if you have SortColumns defined the grid needs to honor that sort order when values change. But if you make sure that none of these fields affect the sort order that should be no problem and no record will be rearranged.
If the underlying datasource the grid reacts to ListChanged event from that datasource when a record is changed. It tells the grid to remove the record from a specific position and insert it in another position. The only way to prevent this from happening would be to tell the grid to use its own sort order by specifying SortedColumns. Then that sort order will have precedence over the sort order of the underlying datasource. And if your checkbox columns don''t affect the grids sort order the record should stay at the old position.
DLDavid LlewellynSeptember 15, 2004 11:56 PM
I have added fields to the SortColumns, but these are not any of the checkbox fields.
The only time I sort the underlying datasource is when I retrieve the data from my datatable. But that is done by SQL.
The records shift when they are clicked on, but they dont seem to sort themselves in order of the checkboxes ''true'' and ''false'' values.
Any idea''s why these are shifting around??
ADAdministrator Syncfusion Team September 16, 2004 11:12 AM
I assume that the underlying DataTable.DefaultView raises ListChanged events becuase the rows in that table are shifted around.
You could find out about this by listening to DataTable.DefaultView.ListChanged event and see what events are raised.
Is there any field in your table that you could sort on? That field could take precedence ahead of the underlying datasource.
If you keep on having problems just prepare a small sample and then I can debug into it.
DLDavid LlewellynSeptember 19, 2004 10:25 PM
Thank you for your help. I found out that the ListChanged event is being raised (like you said) and the message that is being sent, when the checkbox is clicked, is "ItemChanged".
I can simply ignore these events by using the following line of code :-
if (e.ListChangedType.ToString() == "ItemChanged") return;
Now the records do not shift around.