jQuery UI Widgets Forums DataTable datatable reset sorting and filter for dynamic table

This topic contains 4 replies, has 4 voices, and was last updated by  Peter Stoev 3 months, 2 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author

  • SJ
    Participant

    Hi,

    I am creating a dynamic datatable with server side processing. The issue is where I am replacing previous dynamic grid with new grid, previously applied filtering and sorting persists in newly loaded datatable. I tried to resolve this issue by applying clearfilter and data.$sortdatafield = null;, but that results in calling the server multiple times. Is there a way I can reset the datatable’s sort/filter without communicating with the server.

    var source = {
    dataType : “json”,
    url : url
    };
    var columns;

    var dataAdapter = new $.jqx.dataAdapter(source, {
    formatData : function(data) {//called twice after call ‘clearfilter’
    if (columnRendered == false) {
    data.$skip = 0 * data.pagesize;
    data.$sortdatafield = null;
    } else {
    data.$skip = data.pagenum * data.pagesize;
    }
    data.$top = data.pagesize;
    data.$inlinecount = “allpages”;
    return data;
    },

    loadError : function(xhr, status, error) {
    throw new Error(error.toString());
    },
    beforeLoadComplete : function(records, original) {
    columns = original.columns;
    if (columnRendered == false) {
    $(“#viewDataTable”).jqxDataTable({
    columns : columns
    });

    }
    columnRendered = true;
    totalNumberOfRecords = original.totalNumberOfRecords;
    source.totalRecords = totalNumberOfRecords;
    return original.rows;
    }
    });

    if (totRows != undefined) {
    $(“#viewDataTable”).jqxDataTable({
    source : dataAdapter
    });
    } else {
    $(“#viewDataTable”).jqxDataTable({
    width : ‘99%’,
    theme : ‘bootstrap’,
    autoRowHeight : true,
    altRows : true,
    height : “98%”,
    columnsHeight : 50,
    source : dataAdapter,
    sortable : true,
    editable : false,
    columnsResize : true,
    pageable : true,
    pageSize : 20,
    pageSizeOptions : [ ’20’, ’50’, ‘100’ ],
    pagerMode : “advanced”,
    serverProcessing : true,
    filterable : true,
    filterMode : ‘simple’

    });
    }


    Hristo
    Participant

    Hello SJ,

    You could try to use $("#dataTable").jqxDataTable('sortBy', null); and $("#dataTable").jqxDataTable('clearFilters'); in the desired moment.
    Please, take a look at those examples – Sorting API and Filtering API.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com


    sergion
    Participant

    Hello,

    Is there a full example of a jquery datatable server-side processed with sorting and filtering enabled?

    Thanks!


    sergion
    Participant

    Better saying, a jquery GRID server-side processed with sorting and filtering enabled

    Thanks!


    Peter Stoev
    Keymaster
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.