jQuery UI Widgets › Forums › DataTable › datatable reset sorting and filter for dynamic table
Tagged: angular datatable, angular2 datatable, bootstrap datatable, javascript datatable, jquery datatable, jqwidgets datatable, jqxdatatable, typescript datatable
This topic contains 4 replies, has 4 voices, and was last updated by Peter Stoev 5 years, 4 months ago.
-
Author
-
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’});
}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 HristovjQWidgets team
http://www.jqwidgets.comHello,
Is there a full example of a jquery datatable server-side processed with sorting and filtering enabled?
Thanks!
Better saying, a jquery GRID server-side processed with sorting and filtering enabled
Thanks!
Hi sergion,
You may look at: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxdatatable/jquery-datatable-extra-http-variables.htm
Best Regards,
Peter StoevjQWidgets team
https://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.