Ext之grid右键菜单
2012-08-31 15:19
330 查看
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());
});
};
};
[javascript] view
plaincopy
var rightMenu = new Ext.ux.grid.RightMenu({
items : [{
text : '增加',
recHandler : onAdd
}, {
text : '删除',
recHandler : function(record, rowIndex, grid) {
alert(1);
}
}]
});
只需要将上面代码作为插件使用就OK了
[javascript] view
plaincopy
selModel : new Ext.grid.RowSelectionModel({
singleSelect : true
}),
plugins : [rightMenu],
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());
});
};
};
[javascript] view
plaincopy
var rightMenu = new Ext.ux.grid.RightMenu({
items : [{
text : '增加',
recHandler : onAdd
}, {
text : '删除',
recHandler : function(record, rowIndex, grid) {
alert(1);
}
}]
});
只需要将上面代码作为插件使用就OK了
[javascript] view
plaincopy
selModel : new Ext.grid.RowSelectionModel({
singleSelect : true
}),
plugins : [rightMenu],
相关文章推荐
- Ext.Net 1.x_Ext.Net.GridPanel之右键菜单
- Ext.Net 1.x_Ext.Net.GridPanel之右键菜单
- Ext之grid右键菜单
- Ext的Grid右键菜单代码
- Ext教程连载 - 带右键菜单的树
- ext2.2打造全新功能grid系列--右键菜单篇
- Ext之GridPanel实现鼠标右键删查改功能
- Extjs 4.0.7 gridPanel记录添加右键菜单事件
- 为lazyTreeGrid添加右键菜单
- 在StringGrid中用右键菜单实现复制粘贴
- S2SH整合构建Ext动态树(带右键菜单操作)
- Ext之GridPanel实现鼠标右键删查改功能
- Ext 4.2 添加右键菜单
- ext desktop桌面右键弹出菜单代码
- 【ext.net 1.0】GridPanel 的插件 GridFilter 过滤组件,ListFilter过滤菜单不自动滚动的问题解决
- ext树节点 右键菜单(叶的和非叶子的邮件菜单不一样)
- ext desktop桌面图标的右键弹出菜单代码
- Ext 带右键菜单的树
- [Ext.Net]GridPanel行选择右键菜单
- UltraWebGrid右键菜单在Excel上复制粘贴