jQWidgets Forums
Forum Replies Created
-
Author
-
In my case, I want remote pagination, and I also want remote sorting. At first settings, my sorting didn’t work either. After adding the mentioned sorting mechanism, my sorting worked. I thought you have the same problem. Sorry if I didn’t understand your problem correctly.
Hi,
Based on what I got from PHP and Java examples of jQWidgets, the default sorting is done locally. To enable remote sorting, you should set sort function in the data source and in the set function, call $(‘#<id>’).jqxGrid(‘updatebounddata’, ‘sort’).
In example http://jspexamples.jqwidgets.com/examples/grid-sorting-paging-filtering.htm?arctic, the data source is as follows:
var source = {
datatype: “json”,
datafields: [{
name: ‘FirstName’,
type: ‘string’
}, {
name: ‘LastName’,
type: ‘string’
}, {
name: ‘Title’,
type: ‘string’
}, {
name: ‘BirthDate’,
type: ‘date’
}],
cache: false,
url: ‘jsp/select-filtered-data.jsp’,
filter: function() {
// update the grid and send a request to the server.
$(“#jqxgrid”).jqxGrid(‘updatebounddata’, ‘filter’);
},
sort: function() {
// update the grid and send a request to the server.
$(“#jqxgrid”).jqxGrid(‘updatebounddata’, ‘sort’);
},
beforeprocessing: function(data) {
if (data != null && data.length > 0) {
source.totalrecords = data[0].totalRecords;
}
}
};
var filterChanged = false;
var dataadapter = new $.jqx.dataAdapter(source, {
/*
// remove the comment to debug
formatData: function(data) {
alert(JSON.stringify(data));
return data;
},*/
downloadComplete: function(data, status, xhr) {
if (!source.totalRecords) {
source.totalRecords = data.length;
}
},
loadError: function(xhr, status, error) {
throw new Error(error);
}
}); -
AuthorPosts