Page 46 of 92 FirstFirst ... 36444546474856 ... LastLast
Results 451 to 460 of 914

Thread: Grid Filter (Plugin)

  1. #451
    Ext User
    Join Date
    May 2008
    Posts
    5
    Vote Rating
    0
      0  

    Talking omg...

    Didn't know that this existed =( I was struggling all morning with some colleagues to know how to filter on our grids... until I saw this it's a bit too long to read all the js files though, is there a particular order or specific set of files which I can modify to adapt the plugins to my data? for the moment I'm assuming it is [ambience's source root]\ux\grid\GridFilter.js, am I right?

    btw, thanks for your great filter I tried the demo @ your site and works just fine

  2. #452
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    8
      0  

    Default

    Quote Originally Posted by el_dark View Post
    Didn't know that this existed =( I was struggling all morning with some colleagues to know how to filter on our grids... until I saw this it's a bit too long to read all the js files though, is there a particular order or specific set of files which I can modify to adapt the plugins to my data? for the moment I'm assuming it is [ambience's source root]\ux\grid\GridFilter.js, am I right?

    btw, thanks for your great filter I tried the demo @ your site and works just fine
    I believe this plugin is now included in the download package, so there's a working version in your local download. Check the various grid demos.

  3. #453
    Ext User
    Join Date
    May 2007
    Posts
    45
    Vote Rating
    0
      0  

    Default

    not sure. but i think there's a bug in RangeMenu.js.

    i tried to use the fieldCfg without success. After changing the fields creation the config worked like expected. i'm not sure what cfg.gt, cfg.lt and cfg.eq stands for, but if a config object is passed it will never work. changing the lines to this helped me out.

    Code:
    PHP Code:
        var fields this.fields Ext.applyIf(this.fields || {}, {         'gt': new Ext.ux.menu.EditableItem({             icon:  this.icons.gt,             editor: new cls(typeof cfg == "object" cfg || '' cfg.gt)}),         'lt': new Ext.ux.menu.EditableItem({             icon:  this.icons.lt,             editor: new cls(typeof cfg == "object" cfg || '' cfg.lt)}),         'eq': new Ext.ux.menu.EditableItem({             icon:   this.icons.eq,              editor: new cls(typeof cfg == "object" cfg || '' cfg.eq)})     }); 

  4. #454
    Sencha User mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
      0  

    Default

    @pantarhei

    configs for greater than (gt), less than (lt) and equals (eq)?

  5. #455
    Ext User
    Join Date
    May 2008
    Posts
    5
    Vote Rating
    0
      0  

    Default Grid & Gild Filter Ruby on Rails back end code

    Hi. This is a RoR and Ext newbie's take on the Grid and Grid Filter RoR back end code after reading through this forum. Thanks to ambience for this plugin and thanks to Zyclops for his example. Hope it will be useful for someone.

    Update: It now correctly handles the 'list' filter type with more than one value. Make sure phpMode is true in the javascript filters definition: e.g. filters = new Ext.ux.grid.GridFilters({filters:[ {type: 'list', dataIndex: 'col1', options: ["1", "2", "3"], phpMode: true}, ...

    Code:
    def grid_filter
        minlimit = 15    #Minimun number of rows displayed
    
        gf_offset = (params[:start] || 1).to_i
        gf_limit = (params[:limit] || minlimit).to_i
        gf_sortcol = (params[:sort] || 'created_at')
        gf_sortdir = (params[:dir] || 'DESC')
    
        gf_total = Datatable.count
    
        if gf_offset > gf_total
          gf_offset = gf_total
        elsif gf_offset < 0
          gf_offset = 0
        end
    
        if gf_limit <= minlimit
          gf_limit = minlimit
        end
    
        if not Datatable.column_names.include?(gf_sortcol.to_s)  #Verify sort column field name
          gf_sortcol = 'created_at'
        end
    
        if gf_sortdir != 'ASC' and gf_sortdir != 'DESC'
          gf_sortdir = 'DESC'
        end
    
        records = Datatable.find(:all,
          :conditions => buildFilterOptions(params[:filter]),  #Get grid filter SQL condition string
          :limit => gf_limit,
          :offset => gf_offset,
          :order => gf_sortcol + ' ' + gf_sortdir)
    
        render :json => {:total => gf_total.to_s, :rows => records}
      end
    
      def buildFilterOptions(filter_hash)
    
        return '' if filter_hash.nil?  #Return an empty string if the filter is empty
    
        fs = ''
    
        filter_hash = filter_hash.delete_if {|key, value| value.blank? }
        filter_hash.each do |columns, fvals|
          fs_tmp = ''
    
          gf_field = fvals[:field].downcase
          gf_type = fvals[:data][:type].downcase
          gf_type = '' unless Datatable.column_names.include?(gf_field)  #Verify field name
          gf_value = fvals[:data][:value]
          gf_comparison = fvals[:data][:comparison]
    
          case gf_type
            when 'numeric'
              case gf_comparison
                when 'gt'
                  fs_tmp = '>'
                when 'lt'
                  fs_tmp = '<'
                when 'eq'
                  fs_tmp = '='
                when 'ne'
                  fs_tmp = '!='
              end
              gf_value = gf_value.to_i
              fs_tmp = gf_field + ' ' + fs_tmp + ' ' + gf_value.to_s unless fs_tmp.empty?
            when 'string'
              fs_tmp = gf_field + ' like \'%' + gf_value + '%\''
            when 'boolean'
              gf_value = gf_value.downcase
              if gf_value == 'true' or gf_value == 'false'
                fs_tmp = gf_field + ' = ' + gf_value
              end
            when 'list'
              fs_tmp = buildFilterOptions_List(gf_value, gf_field)  #Need to implement your own data validation
            when 'date'
              case gf_comparison
                when 'gt'
                  fs_tmp = '>'
                when 'lt'
                  fs_tmp = '<'
                when 'eq'
                  fs_tmp = '='
                when 'ne'
                  fs_tmp = '!='
              end
              #Note: I modified DateFilter.js 'dateFormat' from 'm/d/Y' to 'Y-m-d'
              fs_tmp = gf_field + ' ' + fs_tmp + ' \'' + gf_value + '\'' unless fs_tmp.empty?
          end
    
          if not fs_tmp.empty?
            fs = fs + ' AND ' unless fs.empty?
            fs = fs + fs_tmp
          end
        end
    
        fs
      end
    end
    
    def buildFilterOptions_List(val, key)
    
      if val.nil? or val.empty? or key.nil? or key.empty? then return val end
    
      skey = key + ' = '
      rtn = ''
      cnt = 0
      if val.include? ','
        val.split(',').each {|sval|
          rtn = rtn + ' OR ' unless cnt < 1
          rtn = rtn + skey + sval
          cnt += 1
          }
        rtn = '(' + rtn + ')' unless cnt <= 1 
      else
        rtn = skey + val
      end
      rtn
    end

  6. #456
    zhiliang
    Guest

    Default list filter jsonstore

    hello, first thanks for this great plugin, it's awesome

    I try to use the jsonstore to update the List filter, but it doesn't work very well, first it can not pass the right data to the server side,


    my store is like this:

    PHP Code:
     var teamstore = new Ext.data.Store({
               
    proxy: new Ext.data.HttpProxy({
               
    url'./php/backend.php',
                
    method'POST'
            
    }),
            
    baseParams:{task"showTeam"},
            
    reader:  new Ext.data.JsonReader({
                
    root'team'
            
    }, [
                {
    name'text'mapping 'team'},
                {
    name'team'mapping 'team'
                 
                ])
                }); 
    then i set the list filter:

    {type: 'list', dataIndex: 'team', store: teamstore, phpMode: true},

    it shows correct but i check the firebug that every time it send some numbers as the filter value, so i check the ListFilter.js and I found it will send the item id as value, i made some changes:

    in onLoad function i add:

    item.value = records[i].get(this.labelField);

    and in checkChange

    this.menu.items.each(function(item){
    if(item.checked)
    value.push(item.value);
    },this);

    It seems work fine, but there is new problem, teamstore is based on some other comboboxes, so the data will change when they update, if I do not uncheck the menuItem and only uncheck the filter menu , it will keep the value in the Fliter, so next time when the grid update , even in the filter list there is not these menuItem anymore, it will still send the old values to the server, anyone know how to solve this problem? thx


    Figure it out, onLoad() add this.value = [];
    Last edited by zhiliang; 5 Jun 2008 at 6:17 AM. Reason: Figure it out

  7. #457
    Ext GWT Premium Member
    Join Date
    Sep 2007
    Location
    Brno, Czech Republic
    Posts
    5
    Vote Rating
    0
      0  

    Default More columns in large list filter

    Is it possible to use more than one column in large list filter?
    Attached Images Attached Images

  8. #458
    Sencha User
    Join Date
    May 2007
    Location
    Germany
    Posts
    84
    Vote Rating
    1
      0  

    Default

    Quote Originally Posted by stradej View Post
    Is it possible to use more than one column in large list filter?
    not two columns, but i use this for long menus:
    Code:
    Ext.override(Ext.menu.Menu,{
        listeners:{    // Make long menus scrollable
            show : function(m) {
                var maxHeight = Ext.getBody().getHeight() - 30;
                if (m.el.getHeight()+m.el.getY() > maxHeight) {
                    m.el.setHeight(maxHeight-m.el.getY());
                    m.el.applyStyles('overflow:auto;');
                }
            }
        }
    });

  9. #459
    Ext User
    Join Date
    Jun 2008
    Posts
    30
    Vote Rating
    0
      0  

    Exclamation grid filter code

    Hello,

    Can anyone pls point me to where I can get the Grid-filter example code.
    I saw the demo and it seems really good.. It would be great if someone could help me implement it.

  10. #460

Page 46 of 92 FirstFirst ... 36444546474856 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •