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

Newly inserted records go to the top of the grid

When a user inserts a row to the grid and do a database update, the newly inserted records go to the top of the grid. Is there a way to solve this problem (ie to preserve the position of the inserted row)? Thanks in advance

4 Replies

AD Administrator Syncfusion Team March 2, 2004 11:46 AM

The grid just reflects what the datasource does. So, if the datasource sorts the new values, the grid displays them sorted. If you grid is sorted, then when new data is saved, it will automatically be position properly with respect to sort order. The only way to avoid this without going to historic effects is to not have the data sorted when you want to edit it.


GG Gene Gorokhovsky March 16, 2004 07:50 AM

Actually the fact that edited and new record "jump" around when user edits them and datasource is sorted is slighly annoying. Here is a way to work around that: *Create a class derived from DataView. *In it, add an integer column to your datasource. *Override IBdindingList.ApplySort to sort by requested column, then copy row numbers into this new special "sort freezer" column. Set sort internally to be on that column, instead of the one passed to ApplySort. *override other IBindingList interfaces to correctly report publicly visible sort order. If you bind to this derived DataView, edited and new rows are not going to jump until user explicitly clicks column header. I have attached a code fragment that implements the idea outlined above. Gene > The grid just reflects what the datasource does. So, if the datasource sorts the new values, the grid displays them sorted. > > If you grid is sorted, then when new data is saved, it will automatically be position properly with respect to sort order. The only way to avoid this without going to historic effects is to not have the data sorted when you want to edit it.


AD Administrator Syncfusion Team April 26, 2005 11:08 AM

Couldn''t find the attached file. >Actually the fact that edited and new record "jump" around when user edits them and datasource is sorted is slighly annoying. > >Here is a way to work around that: >*Create a class derived from DataView. >*In it, add an integer column to your datasource. >*Override IBdindingList.ApplySort to sort by requested column, then copy row numbers into this new special "sort freezer" column. Set sort internally to be on that column, instead of the one passed to ApplySort. >*override other IBindingList interfaces to correctly report publicly visible sort order. > >If you bind to this derived DataView, edited and new rows are not going to jump until user explicitly clicks column header. > >I have attached a code fragment that implements >the idea outlined above. > >Gene > > > The grid just reflects what the datasource does. So, if the datasource sorts the new values, the grid displays them sorted. >> >> If you grid is sorted, then when new data is saved, it will automatically be position properly with respect to sort order. The only way to avoid this without going to historic effects is to not have the data sorted when you want to edit it. >


AD Administrator Syncfusion Team April 26, 2005 04:23 PM

Hi Bits, Here is the link to the file: http://64.78.52.104/Support/Forums/Uploads/GridDataView.zip Best regards, Jay N

Loader.
Live Chat Icon For mobile
Up arrow icon