Hi,
I have a ultragrid binded to .Net binding source which is binded to a List of a custom class. If dont have sorting set for any column on the grid. The sequence of objects in rows matchs the sequence of objects displayed in the grid. or positiong in binding source is same as display index in grid.
The problem occurs if i sort the grid column. now the row number dont match the position of the row in the binding source or the list. The gid displays the data in the newly sorted format but done not move the data in the undelying binding source to match the UI dispaly index.
Is there is property or a specific binding source that i can use to get these two in sync sutomatically.
Saurabh
Hi Saurabh,
No, the grid can't sort the actual data in your data source, because not all data sources support sorting and there are no sort methods on IBindingList.
You should not rely on row numbers, anyway, because these can change for a wide variety of reasons like sorting, filtering, adding or deleting rows, fixing rows, etc.
If you want to get the underlying data row from a grid row, you can use the ListObject property on the row.
Mike
The reason I need the row numbers in the binding source to match the way its displayed in because I do validations in a presenter class that has access to the property that is binded to the grid and not the actual grid. I add row number to the messages based on the position in the binding source but the user does not see the data on that row because the sorting (thankfully i dont have filtering) has changed the display index of that row. Adding and deleting a row get reflected to the property so they dont cause problem with row number.
The work around for now for me is to remove the sort form all columns when i go an do the validations and re sort the underlying data and re bind it to the grid. This way the row number in the message match the UI index.
I just wanted to know if there is a way to sync the data to be re ordered in the binding source based on the sort on the grid say by using infragistic's binding source or some property. i dont mind using any binding source for which it works. but doing it manually is an over head for this case. i would rather reset everything :-) .
Thanks
Well, another thing you could do is loop through the rows in the grid and examine the ListObject on each row until you find the one you want.
Still another option would be to set the HeaderClickAction in the grid to one of the settings with the word External in it. What this does is it makes the grid's header show the sort indicators but doesn't actually sort the grid data. So you have handle the BeforeSortChange and sort your data source.