EXTJS的Grid 怎样在第一列添加加button????

EXTJS的Grid 怎样在第一列添加加button????,第1张

var grid = new Ext.grid.GridPanel({ cm : new Ext.grid.ColumnModel([{header : '按钮,xtype : 'actioncolumn',width : 90,align : 'center',items : [{text: '按钮'}]}])})

this.colModel = new Ext.grid.ColumnModel({

columns: [

sm1,

{ header: 'id', dataIndex: 'id', width:35,hidden:true  },  // 

{ header: '名称[Name]', dataIndex: "name", width:70, editor: new Ext.form.TextField({allowBlank: false}),},

{ header: ' *** 作',width:60, dataIndex: 'id',renderer:function (v) {

return '<input type="button" value="删除" onClick="javascript: alert('+v+')"'

}}

],

})

menuDisabled: true,

                sortable: false,

                xtype: 'actioncolumn',

                width: 50,

                items: [{

                    iconCls: 'sell-col',

                    tooltip: 'Sell stock',

                    handler: function(grid, rowIndex, colIndex) {

                        var rec = grid.getStore().getAt(rowIndex)

                        Ext.Msg.alert('Sell', 'Sell ' + rec.get('company'))

                    }

                }, {

                    getClass: function(v, meta, rec) {

                        if (rec.get('change') <0) {

                            return 'alert-col'

                        } else {

                            return 'buy-col'

                        }

                    },

                    getTip: function(v, meta, rec) {

                        if (rec.get('change') <0) {

                            return 'Hold stock'

                        } else {

                            return 'Buy stock'

                        }

                    },

                    handler: function(grid, rowIndex, colIndex) {

                        var rec = grid.getStore().getAt(rowIndex),

                            action = (rec.get('change') <0 ? 'Hold' : 'Buy')

                        Ext.Msg.alert(action, action + ' ' + rec.get('company'))

                    }

可以看看官方提供的样例,写的很清楚~~~


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

原文地址: https://outofmemory.cn/bake/11888152.html

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

发表评论

登录后才能评论

评论列表(0条)

保存