EasyUI Forum
April 29, 2024, 05:17:57 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Filter with Format and Numbers  (Read 8682 times)
ahybits
Newbie
*
Posts: 26


View Profile
« on: December 14, 2015, 05:55:02 PM »

Hi

I downloaded the latest filter extension (11/25), but I can seem to get filter to work on a columnt aht has formatted with numbers.  It seems like it only works with text
        field:'completed',
        type:'numberbox',
        options:{precision:2},
        op:['equal','notequal','less','greater']

Thanks
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: December 14, 2015, 06:31:01 PM »

You can override or extend the operators when filtering data, the code below shows how to extend a new operator.
Code:
$.extend($.fn.datagrid.defaults.operators, {
    greater: {
        text: 'Greater',
        isMatch: function(source, value){
            return source > value;
        }
    },
    ngreater: {
        text: 'Greater',
        isMatch: function(source, value){
            return (parseFloat(source)||0) > (parseFloat(value)||0);
        }
    }
})

You also can apply the new operator on the filtering menu.
Code:
op:['equal','notequal','less','ngreater']
Logged
ahybits
Newbie
*
Posts: 26


View Profile
« Reply #2 on: December 16, 2015, 08:53:44 AM »

Thanks

I tweaked it a bit as my source was <div style="....">100</div>

Code:
        ngreater: {
            text: 'Greater',
            isMatch: function(source, value){
                source = $(source).find("div").html()               
                return (parseFloat(source)||0) > (parseFloat(value)||0);
            }
        }

Thanks
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!