I have a grid that I want users to be able to sort with paging. Problem is, when the column is sorted the current pages values are sorted as a subset of the larger dataset. I would like to change the pager index to page 1 following the sort so the user sees the first page of records after the sort.
I have tried setting up a javascript event handler for the AfterColumnSort event. I can get the event to fire and I can reference the grid. I tried setting the grid.currentpageindex = 1 but that didn't work. How on earth can I change the page of the pager back to page 1? I was able to do this server side but the sort occurs after the page is changed, which doesn't help.
Any ideas?
I ended up setting the Pager index to 1 and then calling DataBind on the grid inside the grid's SortColumn event handler. It may not be the most elegant solution, but it gets the job done.
Hello,
For efficiency / speed reasons, UltraWebGrid will sort only what is currently displayed on the page. If you need to sort the whole datasource and not just what is shown on the page you may indeed switch to custom sorting and handle the Sort events your self, sorting the datasource prior to binding the grid (if InitializeDataSource is used, it will be fired after the Sort event)
I am having this same issue. Using AJAX, sorting on server and with my initialize data source event shown below. I have quite a few pages at times (200+) and I want to sort the entire dataset, not just want is currently shown on the page. Is there a simple fix to this or do I need to handle the sort event and sort the dataset myself?
protected void iwgInvoices_InitializeDataSource(object sender, UltraGridEventArgs e) { this.iwgInvoices.DataSource = this.InvoiceFilteredDataSet; }
Nevermind...its not working any longer...I'm stumped.
Okay, I may have found a solution to this problem. I can't say I feel great about it though, it does appear to work.
I added:
Grid.DisplayLayout.Pager.CurrentPageIndex = 1
to the InitializeDataSource Event of my grid. Right after I set the datasource. This seems to work.