ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: orlando_acevedo on July 14, 2017, 12:34:44 am

Title: Infinite scrolling and filtering
Post by: orlando_acevedo on July 14, 2017, 12:34:44 am
Hello all,

What would be the best way to detect when a new filter is triggered (before calling getData), clear the current data and then call refreshDataAndView with the new filter?
At the moment, when a filter is changed, the new data is just added to the current one.

Thank you,

Orlando
Title: Re: Infinite scrolling and filtering
Post by: paramvir on July 14, 2017, 10:28:22 am
Events like filter, filter change listener can be used to detect change in filter.

IN this example https://paramquery.com/pro/demos/infinite_scroll

filter change listener is used to clear the current data cache, call filter method which calls the remote script with new filter parameters.

Code: [Select]
                filter: {
                    condition: 'begin',
                    listeners: [{ 'change': function () {
                        pqIS.init();

                        var $grid = $(this).closest(".pq-grid");
                        $grid.pqGrid('filter', {
                            oper: 'replace',
                            data: [{ dataIndx: 'company', value: $(this).val()}]
                        });
                    }
                    }],
                    type: 'textbox',
                    value: 'P', on: true
                }
Title: Re: Infinite scrolling and filtering
Post by: orlando_acevedo on July 14, 2017, 08:59:14 pm
Thank you for the reply.

This function replaces the entire filter, which means it will ignore the previous fields that have been filtered. Is there a way to restrict the replace to its own column?
Title: Re: Infinite scrolling and filtering
Post by: paramvir on July 14, 2017, 09:40:29 pm
Sure, just use oper: 'add' instead of oper: 'replace' in filter method.
Title: Re: Infinite scrolling and filtering
Post by: orlando_acevedo on July 19, 2017, 07:29:06 pm
Thank you for the information!