extjs网格过滤日期范围

标签 extjs

我不明白如何创建两个日期列并在它们之间创建范围?

例如,我有Grid,其中有一些列(截止日期),并且我有2个日期字段,我可以在其中写入:从哪一天开始直到哪一天 .

那么我如何过滤我选择的那些日子之间的数据?

**SOME CODE:**

   // create the Grid
    var grid = new Ext.grid.GridPanel({
        store       : store,
        id          : 'grid',
        columns     : [
            new Ext.grid.RowNumberer({width: 20, header: '#'}),
            {id:'text',header: "Text", width: 150, sortable: true, dataIndex: 'text'},
            {id:'is_online',header: "Is Online?", width: 70, sortable: true, dataIndex: 'is_online'},
            {id:'deadline',header: "Deadline", width: 130, sortable: true, dataIndex: 'deadline', xtype: "datecolumn", format: "Y-m-d"}
        ],
        stripeRows  : true,
        height      : 550,
        title       : 'Questions',
    });

    var gridSearch = new Ext.Panel({     
        stripeRows  : true,
        frame       : true,
        style       : 'padding-bottom: 5px',
        height      : 250,
        title       : 'Search filter',
        items       : [{
                        xtype       : 'checkbox',
                        id          : 'is_for_online',
                        boxLabel    : 'Показать только ОНЛАЙН',
                        inputValue  : '1'
                      },{
                        xtype       : 'datefield',
                        id          : 'date_s',
                        allowBlank  : true,
                        emptyText   : 'Выберите дату С',
                        name        : 'deadline',
                        width       : 140,
                        editable    : false,
                        format      : 'Y-m-d'
                      },{
                        xtype       : 'datefield',
                        id          : 'date_s',
                        allowBlank  : true,
                        emptyText   : 'Выберите дату С',
                        name        : 'deadline',
                        width       : 140,
                        editable    : false,
                        format      : 'Y-m-d'
                      },{
                        xtype       : 'button',
                        text        : 'Go!',
                        handler     : function () {

                    //var searchValueDate1 = Ext.getCmp("date_s").getValue(); 
                    //var searchValueDate2 = Ext.getCmp("date_po").getValue(); 
                    //var date_s    = searchValueDate1.format('Y-m-d');
                    //var date_po = searchValueDate2.format('Y-m-d');

                    //store.filter("deadline", date_s)//, date_po);

                    alert(daterange);



                        }
                },
                ]
    });

最佳答案

您还可以通过同一属性使用多个过滤器,但为每个过滤器添加不同的 id。 这使得代码更加清晰。

store.filter([
    {
      id: "deadlineStart",
      property: "deadline",
      operator: ">",
      value: new Date(2017, 0, 1)
    },
    {
      id: "deadlineEnd",
      property: "deadline",
      operator: "<",
      value: new Date()
    }
]);

关于extjs网格过滤日期范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8518491/

相关文章:

extjs - 应用程序启动时不应加载带有 autoload true 的存储

html - 如何检索数组对象中的文本?

regex - 使用正则表达式限制文本字段/数字字段中的输入字符?

javascript - ExtJS 能够处理约 1000 个元素的网格/数据存储吗?

javascript - 如何使用 ExtJS 5 Ext.data.Model 字段引用(与 ExtJS 4 中的 ownTo 相比)

javascript - Ext.form.NumberField 中的千位分隔符

javascript - 使用 ExtJs 自动完成文本字段

javascript - 如何在 sencha 的网格中添加页脚

javascript - extjs 和 Internet Explorer 8 的问题

javascript - EXTJS 5 树网格自定义行 css