Author Topic: Infinite scrolling and filtering  (Read 2378 times)

orlando_acevedo

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 27
    • View Profile
Infinite scrolling and filtering
« 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

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Infinite scrolling and filtering
« Reply #1 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
                }

orlando_acevedo

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Infinite scrolling and filtering
« Reply #2 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?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Infinite scrolling and filtering
« Reply #3 on: July 14, 2017, 09:40:29 pm »
Sure, just use oper: 'add' instead of oper: 'replace' in filter method.

orlando_acevedo

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Infinite scrolling and filtering
« Reply #4 on: July 19, 2017, 07:29:06 pm »
Thank you for the information!
« Last Edit: July 19, 2017, 07:33:40 pm by orlando_acevedo »