您的位置:首页 > 其它

Ext之grid右键菜单

2012-08-23 21:13 344 查看
Ext.ns('Ext.ux.grid');
Ext.ux.grid.RightMenu = function(options) {
var currRecord = false;
var currRowIndex = false;
var currGrid = false;
var menuItems = Ext.each(options.items, function() {
var item = this;
this.handler = function() {
item.recHandler
&& item.recHandler(currRecord, currRowIndex,
currGrid);
};
});
var menu = new Ext.menu.Menu({
items : options.items
});
this.init = function(grid) {
grid.addListener('rowcontextmenu', function(client, rowIndex, e) {
e.preventDefault();
if (rowIndex < 0) {
return;
}
client.getSelectionModel().selectRow(rowIndex);
currRowIndex = rowIndex;
currRecord = grid.getStore().getAt(rowIndex);
currGrid = grid;
menu.showAt(e.getXY());
});
};
};


var rightMenu = new Ext.ux.grid.RightMenu({
items : [{
text : '增加',
recHandler : onAdd
}, {
text : '删除',
recHandler : function(record, rowIndex, grid) {
alert(1);
}
}]
});


只需要将上面代码作为插件使用就OK了

selModel : new Ext.grid.RowSelectionModel({
singleSelect : true
}),
plugins : [rightMenu],
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ext function plugins menu