【问题标题】:Extjs 3 (Grid Filter)Extjs 3(网格过滤器)
【发布时间】:2011-12-14 14:58:51
【问题描述】:
fbar :[{
                    xtype       : 'datefield',
                    id          : 'date_s',
                    allowBlank  : true,
                    emptyText   : 'Choose date',
                    name        : 'deadline',
                    width       : 120,
                    editable    : false,
                },{
                    xtype       : 'button',
                    text        : 'Go!',
                    handler     : function () {
                     /*f.load({
                        params : {
                            start : 0,
                            limit : 2,
                            t : ''
                        }
                    });*/

                    var clear = f.clearFilter();
                    var searchValueDate1 = Ext.getCmp("date_s").getValue(); 
                    var date1 = searchValueDate1.format('Y-m-d); // 00:00:00');

                    //alert(date1);

                    //clear;
                    f.load().filter("question[deadline]", date1);

                    }
                }]

我创建了组合框,我可以在其中选择任何日期,然后当我单击按钮时 -> 它只显示只有该日期的行 9deadline 日期) 问题:我认为我写的一切都是正确的,但不起作用!主要问题是什么?

【问题讨论】:

    标签: extjs


    【解决方案1】:

    你说的不起作用是什么意思?你有错误吗?

    在 ExtJs 3 中,过滤器是一个小部件,它允许您具有视觉功能来选择日期,然后,它会启动一个事件(加载),如果您需要在过滤完成之前更改数据,则必须捕获该事件(加载)控制器(在 asp/php 中)

    给我们一个完整的测试代码,以便在我们的环境中简单地过去

    【讨论】:

      【解决方案2】:

      处理程序获取传递给它的按钮和事件对象。所以处理程序应该是这样的:

      handler     : function (b,e) {
      
      var theGrid = Ext.getCmp('gridId'); //You need to get the grid to filter
      var theStore = theGrid.store; //Get the grid store you need it to filter
      
      var searchValueDate1 = Ext.getCmp("date_s").getValue(); 
      var date1 = searchValueDate1.format('Y-m-d); // 00:00:00');
      
      
      //Filter by filters each record if true it keeps it if false it filters it out
      theGrid.filterBy(function(rec){
      
      if(rec.get('dateField') == date1 ){
        return true
      }else{
       return false;
      }
      });
      
      }
      

      这是一个基本的想法,复制和粘贴是行不通的,它更多的是作为指导。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-06-12
        • 2012-02-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多