jQuery UI Widgets Forums Grid clearfilters with multiple filters

This topic contains 4 replies, has 2 voices, and was last updated by  Hristo 5 years, 3 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • clearfilters with multiple filters #94065

    mkrajew
    Participant

    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.

    clearfilters with multiple filters #94066

    mkrajew
    Participant

    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 });
    
    clearfilters with multiple filters #94091

    Hristo
    Participant

    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 Hristov

    jQWidgets team
    http://www.jqwidgets.com

    clearfilters with multiple filters #94103

    mkrajew
    Participant

    My 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;
                    }
                });
    clearfilters with multiple filters #94118

    Hristo
    Participant

    Hello mkrajew,

    I look into the shared example and everything looks fine.
    I cannot find where you use clearfilters method and you do not have any error message.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.