Author Topic: filter in column with datatype integer  (Read 3056 times)

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
filter in column with datatype integer
« on: February 07, 2016, 09:02:09 pm »
Hi

I use in ColModel

...
dataType: "integer", filter: { type: 'textbox', condition: 'begin',
...

when I use condition: 'contains' I get error: "Uncaught TypeError: f is not a function"

How can I use datatype integer and filter with contains condition?

thanks



paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: filter in column with datatype integer
« Reply #1 on: February 08, 2016, 10:27:36 am »
contain condition works with dataType: string

Callback could be used for numbers:
Code: [Select]
condition: function(a, b){
if ( ( a + "" ).indexOf( ( b + "" ) ) >= 0 ){
return true;
}
},
« Last Edit: February 08, 2016, 10:29:58 am by paramquery »

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: filter in column with datatype integer
« Reply #2 on: February 08, 2016, 03:10:02 pm »
tried:

Code: [Select]
{title:"columnd", width:90, dataIndx: "columnd", dataType: "integer", filter: { type: 'textbox', condition: function(a, b){
    if ( ( a + "" ).indexOf( ( b + "" ) ) >= 0 ){
        return true;
    }, listeners: ['keyup']}
}},

doesn't work...where to place the callback to function properly?

thanks
« Last Edit: February 08, 2016, 03:40:53 pm by queensgambit9 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: filter in column with datatype integer
« Reply #3 on: February 08, 2016, 05:30:17 pm »
Please recheck:

Code: [Select]
condition: function(a, b){
      b = isNaN(b)? "": b+"";
        a = a+"";
        if ( !b.length || a.indexOf( b ) >= 0 ){
               return true;
        }
},


http://jsfiddle.net/b6b710mz/116/

Note that leading zeros are ignored with this method e.g., if 051 is entered in textbox, it would search for 51 in the cells.
« Last Edit: February 08, 2016, 05:42:47 pm by paramquery »