Author Topic: Refresh filter select  (Read 2337 times)

groupXS

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 9
    • View Profile
Refresh filter select
« on: February 02, 2018, 01:48:48 pm »
Hi,

I have filter select (drop down) with all distinct values for current column.

                        filter: {
                            type: "select",
                            listeners: ['change'],
                            prepend: { '': i18n.t('local:common.pleaseSelect') },
                            options: paramQueryService.getCallbackFilterOptions(),
                            condition: filterCondition
                        }

in getCallbackFilterOptions
        return function (ui) {
            var distinctValues: any[] = grid.getData({ 'dataIndx': [ui.dataIndx] });
            ...
            return distinctValues;
        };

and filter is working, but I would like to refresh this list in case user change some data in any that column.

Is there any API call that will force filter to call callback function attached to filter.options and refresh items in select? Or is there any other way to do that?
I was playing with
$( ".selector" ).pqGrid( "refresh" );
$( ".selector" ).pqGrid( "refreshDataAndView" );
grid.refreshHeaderFilter({ dataIndx: 'ShipRegion' });
but even it calls that callback, items remains same

If I have to do it manually. I was thinking to listen to cellSave event and to use
grid.getData({ 'dataIndx': [dataIndx] });
to get all distict value, but then to use jQuery to access that select and somehow sync values.

Thank you.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: Refresh filter select
« Reply #1 on: February 02, 2018, 07:20:29 pm »
This is example where ShipRegion filter options are changed dynamically https://paramquery.com/pro/demos/filter_cascade


In your case, change is more appropriate event.

Code: [Select]
change: function(){
  this.getColumn({ dataIndx: 'ShipRegion' }).filter.cache = null;
  grid.refreshHeaderFilter({ dataIndx: 'ShipRegion' });
}