Author Topic: Dropdown filter with default selection  (Read 5908 times)

TonyLeech

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Dropdown filter with default selection
« on: September 15, 2015, 04:40:22 pm »
I'm using the 'select' filter with dropdown entries supplied in colM variable like this...

options: [{transstatus:'Live', pq_selected:true},{transstatus:'Dead'}]

The 'Live' option is displayed in the dropdown by default due to the pq_selected:true, but the table doesn't filter 'Live' by default when initialized.  Is there another setting/option required to enforce the pq_selected action on the table not only in the header?  I can confirm that the selector is working and properly selects 'Live' if manually changed to 'Dead' then returned to 'Live'.

Thanks in advance.

Tony

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Dropdown filter with default selection
« Reply #1 on: September 16, 2015, 02:52:00 pm »
you might need to refresh the filter ( by calling filter method ) on grid initialization.

grid.filter ({ oper: 'add', data: [] });

TonyLeech

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Re: Dropdown filter with default selection
« Reply #2 on: September 16, 2015, 04:22:13 pm »
Thanks for your suggestion.  I'm sure you will be right, but I'm still getting familiar with how and where to write the various structures and functions, could you give me a little more guidance with where to place the grid.filter({oper:'add', data:[]});

Thanks again.

Tony

TonyLeech

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Re: Dropdown filter with default selection
« Reply #3 on: September 18, 2015, 09:57:17 pm »
Thanks for your suggestion.  I'm sure you will be right, but I'm still getting familiar with how and where to write the various structures and functions, could you give me a little more guidance with where to place the grid.filter({oper:'add', data:[]});

Thanks again.

Tony

I hope you will be able to help me complete the above filter initializing.  I've tried to work out where and how to call the filter method on grid initialization but I'm obviously not doing it right.  Can you point me at a demo that uses a default initialized filter, or show me how to use the grid.filter({oper:'add', data:[]}) code you kindly submitted a couple of days ago?

I' d appreciate your guidance.  Many thanks.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Dropdown filter with default selection
« Reply #4 on: September 19, 2015, 11:13:06 am »
Please check this demo to apply initial filtering by calling filter method:

http://paramquery.com/pro/demos/filter_header

And another way to apply initial filter by setting initial values in column.filter:

http://paramquery.com/pro/demos/filter_initial
« Last Edit: September 19, 2015, 12:23:00 pm by paramquery »

TonyLeech

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Re: Dropdown filter with default selection
« Reply #5 on: September 27, 2015, 11:54:56 pm »
Brilliant.  Works a treat.

Sorry for the delayed response...I've been out of the office for a week.  Many thanks for your kind support.

Best regards

Tony