Author Topic: Custom filter with paramquery pro 3.3.5  (Read 2106 times)

WTC_User

  • Pro OEM
  • Newbie
  • *
  • Posts: 18
    • View Profile
Custom filter with paramquery pro 3.3.5
« on: September 28, 2017, 06:37:28 pm »
Hi all,

I need to create a simple textarea header filter (remote filter) but I want that the filter will be applied only if the search query has a min length (like 3).
I immagin that i've to create a custom listener...that's correct?

In the api documentation I found that:
"listeners is an array used to bind control with the events upon firing of which a callback function is called.
Format is listeners: [ { 'name of event' : function( evt, ui ){ } } ,... ] where ui in the callback is an object holding the following properties."

so I've create this:
filter: {
       type: 'textbox',
       condition: 'contain',
       listeners: [{
            'myEvent': function (evt, ui) {
                  //?? return ui.value.length>2; ??
             }
       }]
}

But nothing to do! What I've to write to fire the filter?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Custom filter with paramquery pro 3.3.5
« Reply #1 on: September 28, 2017, 09:45:17 pm »
Custom listener is created this way. The keyname of listener should be a valid DOM event name like change, input, keyup, downdown, etc.

Code: [Select]
      filter: {
        type: 'textbox',       
        listeners:[{"keyup": function(evt, ui) {
        var len = ui.value.length;
        if(len > 2 || len==0){
          grid.filter({
              data: [{dataIndx: ui.dataIndx, value: ui.value, condition: 'contain'}]
                 });
                }
        }}]
      }

http://jsfiddle.net/djdfk7yd/

WTC_User

  • Pro OEM
  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Custom filter with paramquery pro 3.3.5
« Reply #2 on: September 29, 2017, 02:08:59 pm »
Thank you so much man! 8)