jQWidgets Forums

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: grid is not sorting grid is not sorting #80208

    mbizhani
    Participant

    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.

    in reply to: grid is not sorting grid is not sorting #80203

    mbizhani
    Participant

    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);
    }
    });

Viewing 2 posts - 1 through 2 (of 2 total)