Ext中gridpanel每行后面可编辑、删除,使用actioncolumn

如下代码:

var ac = {
         xtype: 'actioncolumn',
         header: '操作',
         width: 50,
         items: [{
             icon   : basePath + '/resources/images/edit.gif',  // Use a URL in the icon config
             tooltip: '编辑',
             handler: function(grid, rowIndex, colIndex) {
             var store = Ext.getCmp("mygrid").getStore();
                var value = store.getAt(rowIndex);
                initStore(storeDept);
               
                //获取编辑window窗口
var windowedit = Ext.getCmp("windowedit");
if(!Ext.value(windowedit)){
editFun(storeDept, value, "");
}
             }
         },{
             icon   : basePath + '/resources/images/remove.png',  // Use a URL in the icon config
             tooltip: '删除',
             handler: function(grid, rowIndex, colIndex) {
             Ext.MessageBox.confirm("确认",'是否确认删除?',function(btn){
             if('yes' == btn){
             var store = Ext.getCmp("mygrid").getStore();
                var value = store.getAt(rowIndex);
                var departmentId = value.get('departmentId');
                deleteFun(departmentId);
             }
             });
             }
         }
         ]
};

创建好actioncolumn对象之后,把它添加到columnModel数组中去,即可实现,都试试吧

你可能感兴趣的:(ext)