jQuery UI Widgets › Forums › Grid › clearfilters with multiple filters
Tagged: #jqwidgets-grid, clearfilters, filters, grid, javascript grid, jquery grid, jqxgrid
This topic contains 4 replies, has 2 voices, and was last updated by Hristo 7 years, 4 months ago.
-
Author
-
The clearfilters method doesn’t seem to be working properly if there are more than 1 filter defined.
$('#jqxRecordsGrid').jqxGrid("clearfilters");
The first filter is removed and the grid refrehes only to still have the second filter still applied. I get
Uncaught Error: jqxGrid: The data is still loading. When the data binding is completed, the Grid raises the 'bindingcomplete' event.
in the console log.I suspect that each filter is clearing itself individually and trying to perform an update to the server instead of clearing all the filters first and then performing the update. This is causing two outstanding async requests to the server at the same time which the grid doesn’t like.
Oh, and the workaround is to get the filterinformation and manually remove the filters, then refresh the grid:
var filterInfo = $("#jqxRecordsGrid").jqxGrid('getfilterinformation'); for (var i = 0; i < filterInfo.length; i++) { $("#jqxRecordsGrid").jqxGrid('removefilter', filterInfo[i].filtercolumn, false); } // now rebind $("#jqxRecordsGrid").jqxGrid( { source: m_DataAdapter });
Hello mkrajew,
I tested this example and it seems to work fine.
Could you provide us an example that demonstrates this issue?Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comMy grid is in virtual mode and using a data adapter that gets its data from the server and not local data. I had filters on separate columns. It looks like it was attempting to call the service method more than once when clearfilters is called.
var recordsDataSource = { dataType: "json", datafields: [ { name: 'RecordNumber' }, { name: 'Author' }, { name: 'Title' }, ], sortcolumn: "RecordNumber", sortdirection: "ASC", filter: function () { $('#jqxRecordsGrid').jqxGrid('updatebounddata', 'filter'); }, beforeprocessing: function (data) { var returnData = {}; data = data.d; try { var jsonObj = JSON.parse(data); if (jsonObj.Error) { alert(jsonObj.Error); returnData.totalrecords = 0; returnData.records = []; } else { returnData.totalrecords = jsonObj.totalRows; returnData.records = jsonObj.data; } } catch (err) { console.log(err); if (data) console.log(data); alert(err); } return returnData; }, type: 'get', formatdata: function (data) { data.pagenum = data.pagenum || 0; data.pagesize = data.pagesize || 10; var sortinformation = $('#jqxRecordsGrid').jqxGrid('getsortinformation'); var sortcolumn = sortinformation.sortcolumn; data.sortdatafield = sortcolumn || 'RecordNumber'; data.sortorder = data.sortorder || 'asc'; data.filterscount = data.filterscount || 0; formatedData = buildQueryString(data); return formatedData; }, url: '../Services/MyService.asmx/GetGridRecords' }; this.m_DataAdapter = new $.jqx.dataAdapter(recordsDataSource, { contentType: 'application/json; charset=utf-8', loadError: function (xhr, status, error) { try { var errorObj = JSON.parse(xhr.responseText); $.IPS.ShowMessage(errorObj.Message); } catch (err) { alert(error); } } }); var jqxRecordsGrid = $("#jqxRecordsGrid"); jqxRecordsGrid.jqxGrid( { width: '99.5%', height: 600, sortable: true, pageable: true, pageSize: 100, columnsResize: true, columnsReorder: true, columnsautoresize: false, source: this.m_DataAdapter, selectionmode: "multiplerowsadvanced", virtualmode: true, autoHeight: false, autorowheight: false, pagesizeoptions: ['25', '50', '100', '250'], filterable: true, columns: [ { text: 'No.', dataField: 'RecordNumber', width: 70, filterable: false }, { text: 'Author', dataField: 'Author', width: 150, filtertype: "custom", createfilterpanel: $.Grinder.Records.CreateFilterPanel }, { text: 'Title', dataField: 'Title', width: 250, filtertype: "custom", createfilterpanel: $.Grinder.Records.CreateFilterPanel } ], rendergridrows: function (args) { return args.data; } });
Hello mkrajew,
I look into the shared example and everything looks fine.
I cannot find where you useclearfilters
method and you do not have any error message.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.