extjs4.2怎么在grid.panel里添加搜索

extjs4.2怎么在grid.panel里添加搜索,第1张

features: [{

        ftype : 'groupingsummary',

        groupHeaderTpl : '{name}',

        hideGroupedHeader : false,

        enableGroupingMenu : false

    }, {

        ftype: 'filters',

        local: true

    }, {

        ftype: 'summary',

        dock: 'bottom'

    }],

columns:[ {

        text: 'Name (Filter)',

        sortable: true,

        dataIndex: 'name',

        groupable: false,

        width: 120,

        locked: true,

        renderer: function(v, cellValues, rec) {

            return rec.get('forename') + ' ' + rec.get('surname')

        },

        editor: {

            xtype: 'textfield'

        },

        items    : {

            xtype: 'textfield',

            flex : 1,

            margin: 2,

            enableKeyEvents: true,

            listeners: {

                keyup: function() {

                    var store = this.up('tablepanel').store

                    store.clearFilter()

                    if (this.value) {

                        store.filter({

                            property     : 'name',

                            value         : this.value,

                            anyMatch      : true,

                            caseSensitive : false

                        })

                    }

                },

                buffer: 500

            }

        }

    }]

官方的例子。

大致思路,你参考下:

{

text: '搜索', iconCls:'icon-zoom',

handler: function(btn){ //点击搜索时执行函数

var type= Ext.getCmp('combo_id').getValue() //关键字类型

var value= Ext.getCmp('textfield_id').getValue() //搜索值

var gridSearch = {keyType:type, searchStr:value} //组合成一个对象去传递

var store = Ext.getCmp('grid_id').getStore() //获取grid的store

store.baseParams = {}//绑定参数(在store访问的那个路由中去接收并处理)

store.baseParams['gridSearch'] = Ext.encode(gridSearch)

store.lastOptions.params[store.paramNames.start] = 0

store.removeAll()

store.commitChanges()

store.reload()

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11687389.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-17
下一篇 2023-05-17

发表评论

登录后才能评论

评论列表(0条)

保存