grid.on("rowcontextmenu",function(grid,rowIndex,e)
{
e.preventDefault();if(rowIndex<0){return;}
var treeMenu = new Ext.menu.Menu
([
{xtype:"button",text:"添加",icon:"Images/Icons/button/add.gif",pressed:true,handler:function(){}},
{xtype:"button",text:"编辑",icon:"Images/Icons/button/delete.gif",pressed:true,handler:function(){}},
{xtype:"button",text:"隐藏",icon:"Images/Icons/arrow-down.gif",pressed:true,handler:function(){}},
{xtype:"button",text:"显示",icon:"Images/Icons/arrow-up.gif",pressed:true,handler:function(){}},
{xtype:"button",text:"删除",icon:"Images/Icons/button/cross.gif",pressed:true, handler:function(){}},
{xtype:"button",text:"上传图片",icon:"Images/Icons/plugin_add.gif",pressed:true,handler:function(){}}
]);
treeMenu.showAt(e.getPoint());
});
=============================================================================================
grid.on("rowcontextmenu",function(grid,rowIndex,e) //以下是关键代码
{
//grid 可以是任何参数名称,意思指的就是表示当前的grid
//rowIndex 表示当前行的索引 第一行是0 依此类推
e.preventDefault();//覆盖默认右键
if(rowIndex<0){return;}//如果没有数据就返回
//grid.getStore() 指的是获取当前的存储在客户端的数据集合
//grid.getStore().getAt(rowIndex) 根据当前行的索引获取当前行的数据
var record = grid.getStore().getAt(rowIndex);
//下面具体获取某个属性的值
var number = record.json.Row;//编号
var id = record.data.ID;
var typeCName = record.data.TypeCName;
var delFlag = record.data.DelFlag;
var addDate = record.data.AddDate.format("Y年m月日");
//下面将获取的信息
var treeMenu = new Ext.menu.Menu
([
{
xtype:"button",
text:"显示详细信息",
icon:"../images/add.gif",
pressed:true,
handler:function()
{
//处理在某行上右键时 显示该行的详细信息
var win = new Ext.Window
({
title:"显示在某行右键的详细信息",width:337,height:220,layout:'form',modal:false,resizable:false,
items:
[
{
xtype:"form",
height:200,
labelPad : 0, // 标签与字段录入框之间的空白
bodyStyle : 'padding-top:3px',
frame : true,
defaultType : 'textfield',
labelAlign : 'right',
labelWidth : 81,
defaults : // 容器中组件默认统一配置选项
{
allowBlank : true,width : 200 // 字段宽度
},
items :
[
{fieldLabel:"编号",id:"RowNumber",value:number},
{fieldLabel:"ID",id:"ID",value:id},
{fieldLabel:"中文名称",id:"TypeCName",value:typeCName},
{fieldLabel:"当前状态",id:"DelFlag",value:delFlag},
{fieldLabel:"添加日期",id:"AddDate",value:addDate}
]
}
],
buttons:
[
{xtype:"button",text:"关闭",cls:"x-btn-text-icon",icon:"../images/plugin_add.gif",id:"btnClose",handler:function(){win.destroy();}}
],
buttonAlign:"center"
});
win.show();
}
}
]);
treeMenu.showAt(e.getPoint());
});
==========================================================================
- groupGrid.on("rowcontextmenu", function (grid, rowIndex, e) {
- e.preventDefault();
- if (rowIndex < 0) {
- return;
- }
- var treeMenu = new Ext.menu.Menu ([
- {
- xtype: "",
- text: "详细",
- iconCls: 'context-dog',
- pressed: false,
- handler: function () {
- //获得行数据
- var record = grid.getStore().getAt(rowIndex);
- //open_receive_detailWindow(record.data.smsIndex);
- alert(record.data.company); //company为自定义的字段名称
- //record.data.taskId
- }
- }, {
- xtype: "",
- text: "删除",
- iconCls: 'context-cat',
- pressed: false,
- handler: function () {
- //获得行数据
- var record = grid.getStore().getAt(rowIndex);
- alert(record.data.company);
- }
- }
- ]);
- treeMenu.showAt(e.getXY());
- });
groupGrid.on("rowcontextmenu", function (grid, rowIndex, e) { e.preventDefault(); if (rowIndex < 0) { return; } var treeMenu = new Ext.menu.Menu ([ { xtype: "", text: "详细", iconCls: 'context-dog', pressed: false, handler: function () { //获得行数据 var record = grid.getStore().getAt(rowIndex); //open_receive_detailWindow(record.data.smsIndex); alert(record.data.company); //company为自定义的字段名称 //record.data.taskId } }, { xtype: "", text: "删除", iconCls: 'context-cat', pressed: false, handler: function () { //获得行数据 var record = grid.getStore().getAt(rowIndex); alert(record.data.company); } } ]); treeMenu.showAt(e.getXY()); });