jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Server side sorting
Tagged: datagrid control, grid, jqwidgets grid
This topic contains 3 replies, has 2 voices, and was last updated by vancourse 11 years, 8 months ago.
-
AuthorServer side sorting Posts
-
Hi,
I have been successfully in doing server side sorting, filtering and paging using json-remote-server call. However, I am stuck at the following place. Any help is deeply appreciated:
If I am in Page 2 of 5, and if I hit sort on a field, I get back sorted single-page data from the server – for the CURRENT PAGE ( of 2 in this example).
What I need: I want the sort to get back with data for the first page, Current Page (pagenum) should be set to 1.
Is it possible? If so, how?
Thank you,
Ravi
Hi Ravi,
The “gotopage” Grid method can bring you back to the first page. It accepts number as parameter.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Peter,
Thank you. That is an option. However, since I am also doing server-side paging, hence, a call to “gotopage” will trigger a server call… which I want to avoid… is there any other way? Appreciate your help..
Here are the options that I am using:
this.gridOptions = { width: "100%", source: this.dataAdapter, filterable: false, sortable: true, columnsresize: true, altrows: true, autoheight: true, pageable: true, virtualmode: true,//required, for server side paging rendergridrows: function (obj) { return obj.data; }, columns: this.getColumns(), selectionmode: 'multiplerowsextended', };this.gridDataSourceOptions = { datatype: "json", cache:false, datafields: this.getSchema(), url: this.getWsUri(), sort: (column, direction) => { this.sort(column, direction); }, formatdata: (data) => { this.enhanceDataBeforeRequest(data);}, root: 'Rows', beforeprocessing: (data) => { this.gridDataSourceOptions.totalrecords = data.Grid.TotalItems; } }; this.dataAdapter = new $.jqx.dataAdapter(this.gridDataSourceOptions, { loadServerData: this.getData, loadError: function (xhr, status, error) { alert(error); } });
It worked.. the “gotopage” also retained the “sort” information.. hence I removed the redundant server call upon hitting “sort”. My sort function now looks like this:
public sort(column: string, direction: string)
{
$(#jqxgrid).jqxGrid(‘gotopage’, 0);
} -
AuthorPosts
You must be logged in to reply to this topic.