ExtJs grid行 右鍵菜單的兩種方法
更新時(shí)間:2010年06月19日 12:35:34 作者:
ExtJs grid行 右鍵菜單的兩種方法,需要用extjs制作右鍵菜單的朋友可以參考下。
在這下邊: 方法一
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="gridContextMenu.aspx.cs" Inherits="gridContextMenu" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="< /FONT>http://www.w3.org/1999/xhtml">
<head runat="server">
<title>無標(biāo)題頁</title>
<link rel="Stylesheet" type="text/css" href="ExtJS/resources/css/ext-all.css" />
<link rel="Stylesheet" type="text/css" href="ExtJS/resources/css/xtheme-green.css" />
<script type="text/javascript" src="ExtJS/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ExtJS/ext-all.js"></script>
<script type="text/javascript" src="ExtJS/ext-lang-zh_CN.js"></script>
<style type="text/css">
.panel_icon11 { background-image:url(images/first.gif)}
.center_icon { background-image:url(images/center.png)}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript">
function ready()
{
var url = "jsonGrid.aspx?Param=select";
var sm = new Ext.grid.CheckboxSelectionModel();
var cm = new Ext.grid.ColumnModel
([
sm,new Ext.grid.RowNumberer({header:"編號(hào)",width:50}),
{header:"編號(hào)",dataIndex:"ID",width:10,hidden:true},
{header:"標(biāo)題",dataIndex:"TypeCName",width:100,editor:new Ext.form.TextField()},
{header:"英文名稱",dataIndex:"TypeEName",width:100,editor:new Ext.form.TextField()},
{header:"狀態(tài)",dataIndex:"DelFlag",width:100,renderer:function(value){if(value==false) {return "顯示";} else {return "隱藏";}}},
{header:"添加日期",dataIndex:"AddDate",width:100,renderer:Ext.util.Format.dateRenderer('Y年m月d日')}
]);
cm.defaultSortable = true;
var fields =
[
{name:"ID"},
{name:"TypeCName"},
{name:"TypeEName"},
{name:"DelFlag"},
{name:"AddDate"}
];
var store = new Ext.data.Store
({
proxy:new Ext.data.HttpProxy({url:url}),
reader:new Ext.data.JsonReader({totalProperty:"totalPorperty",root:"root",fields:fields})
});
store.load({params:{start:0,limit:12}});
var pagingBar = new Ext.PagingToolbar
({
displayInfo:true,
emptyMsg:"沒有數(shù)據(jù)顯示",
displayMsg:"顯示從{0}條數(shù)據(jù)到{1}條數(shù)據(jù),共{2}條數(shù)據(jù)",
store:store,
pageSize:12
});
var grid = new Ext.grid.GridPanel
({
id:"MenuGridPanel",
renderTo:document.body,
layout:"fit",
frame:true,
border:true,
width:600,
height:360,
autoScroll:true,
store:store,
sm:sm,
cm:cm,
viewConfig:{forceFit: true},
title:'<img style="height:auto; width:auto;" src="images/first.gif" /> Ext2.2全新功能版系列之--右鍵菜單',
bbar:pagingBar
});
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());
});
}
</script>
<script type="text/javascript">
Ext.onReady(ready);
</script>
</div>
</form>
</body>
</html>
給 Extjs grid 加入右鍵菜單方法二。
grid.on("rowcontextmenu", function (grid, rowIndex, e) {
e.preventDefault();
if (rowIndex < 0) { return; }
var treeMenu = new Ext.menu.Menu
([
{
xtype: "",
text: "詳細(xì)",
iconCls: 'context-dog',
pressed: false,
handler: function () {
//獲得行數(shù)據(jù)
var record = grid.getStore().getAt(rowIndex);
//open_receive_detailWindow(record.data.smsIndex);
alert(record.data.company);
//record.data.taskId
}
}, {
xtype: "",
text: "刪除",
iconCls: 'context-cat',
pressed: false,
handler: function () {
//獲得行數(shù)據(jù)
var record = grid.getStore().getAt(rowIndex);
alert(record.data.company);
}
}
]);
treeMenu.showAt(e.getXY());
});
復(fù)制代碼 代碼如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="gridContextMenu.aspx.cs" Inherits="gridContextMenu" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="< /FONT>http://www.w3.org/1999/xhtml">
<head runat="server">
<title>無標(biāo)題頁</title>
<link rel="Stylesheet" type="text/css" href="ExtJS/resources/css/ext-all.css" />
<link rel="Stylesheet" type="text/css" href="ExtJS/resources/css/xtheme-green.css" />
<script type="text/javascript" src="ExtJS/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ExtJS/ext-all.js"></script>
<script type="text/javascript" src="ExtJS/ext-lang-zh_CN.js"></script>
<style type="text/css">
.panel_icon11 { background-image:url(images/first.gif)}
.center_icon { background-image:url(images/center.png)}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript">
function ready()
{
var url = "jsonGrid.aspx?Param=select";
var sm = new Ext.grid.CheckboxSelectionModel();
var cm = new Ext.grid.ColumnModel
([
sm,new Ext.grid.RowNumberer({header:"編號(hào)",width:50}),
{header:"編號(hào)",dataIndex:"ID",width:10,hidden:true},
{header:"標(biāo)題",dataIndex:"TypeCName",width:100,editor:new Ext.form.TextField()},
{header:"英文名稱",dataIndex:"TypeEName",width:100,editor:new Ext.form.TextField()},
{header:"狀態(tài)",dataIndex:"DelFlag",width:100,renderer:function(value){if(value==false) {return "顯示";} else {return "隱藏";}}},
{header:"添加日期",dataIndex:"AddDate",width:100,renderer:Ext.util.Format.dateRenderer('Y年m月d日')}
]);
cm.defaultSortable = true;
var fields =
[
{name:"ID"},
{name:"TypeCName"},
{name:"TypeEName"},
{name:"DelFlag"},
{name:"AddDate"}
];
var store = new Ext.data.Store
({
proxy:new Ext.data.HttpProxy({url:url}),
reader:new Ext.data.JsonReader({totalProperty:"totalPorperty",root:"root",fields:fields})
});
store.load({params:{start:0,limit:12}});
var pagingBar = new Ext.PagingToolbar
({
displayInfo:true,
emptyMsg:"沒有數(shù)據(jù)顯示",
displayMsg:"顯示從{0}條數(shù)據(jù)到{1}條數(shù)據(jù),共{2}條數(shù)據(jù)",
store:store,
pageSize:12
});
var grid = new Ext.grid.GridPanel
({
id:"MenuGridPanel",
renderTo:document.body,
layout:"fit",
frame:true,
border:true,
width:600,
height:360,
autoScroll:true,
store:store,
sm:sm,
cm:cm,
viewConfig:{forceFit: true},
title:'<img style="height:auto; width:auto;" src="images/first.gif" /> Ext2.2全新功能版系列之--右鍵菜單',
bbar:pagingBar
});
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());
});
}
</script>
<script type="text/javascript">
Ext.onReady(ready);
</script>
</div>
</form>
</body>
</html>
給 Extjs grid 加入右鍵菜單方法二。
復(fù)制代碼 代碼如下:
grid.on("rowcontextmenu", function (grid, rowIndex, e) {
e.preventDefault();
if (rowIndex < 0) { return; }
var treeMenu = new Ext.menu.Menu
([
{
xtype: "",
text: "詳細(xì)",
iconCls: 'context-dog',
pressed: false,
handler: function () {
//獲得行數(shù)據(jù)
var record = grid.getStore().getAt(rowIndex);
//open_receive_detailWindow(record.data.smsIndex);
alert(record.data.company);
//record.data.taskId
}
}, {
xtype: "",
text: "刪除",
iconCls: 'context-cat',
pressed: false,
handler: function () {
//獲得行數(shù)據(jù)
var record = grid.getStore().getAt(rowIndex);
alert(record.data.company);
}
}
]);
treeMenu.showAt(e.getXY());
});
您可能感興趣的文章:
- js禁止頁面復(fù)制功能禁用頁面右鍵菜單示例代碼
- js實(shí)現(xiàn)右鍵菜單功能
- JavaScript 對(duì)任意元素,自定義右鍵菜單的實(shí)現(xiàn)方法
- js右鍵菜單效果代碼
- 深入探討JavaScript、JQuery屏蔽網(wǎng)頁鼠標(biāo)右鍵菜單及禁止選擇復(fù)制
- js實(shí)現(xiàn)右鍵自定義菜單
- JS組件Bootstrap ContextMenu右鍵菜單使用方法
- js捕獲鼠標(biāo)右鍵菜單中的粘帖事件實(shí)現(xiàn)代碼
- javascript自定義右鍵彈出菜單實(shí)現(xiàn)方法
- js實(shí)現(xiàn)右鍵菜單欄功能
相關(guān)文章
Extjs中ComboBox加載并賦初值的實(shí)現(xiàn)方法
當(dāng)需要為ComboBox加載數(shù)據(jù)后進(jìn)行賦初始選中項(xiàng)的話,如果是寫在store.load()之后2012-03-03extjs ColumnChart設(shè)置不同的顏色實(shí)現(xiàn)代碼
extjs為ColumnChart設(shè)置不同的顏色想必有很多朋友還是比較陌生的吧,接下來為大家詳細(xì)介紹下具體設(shè)置代碼,感興趣的朋友可以參考下哈2013-05-05extjs 的權(quán)限問題 要求控制的對(duì)象是 菜單,按鈕,URL
這兩天在解決extjs 的權(quán)限問題。要求控制的對(duì)象是 菜單,按鈕,URL2010-03-03extjs tabpanel限制選項(xiàng)卡數(shù)量實(shí)現(xiàn)思路及代碼
使用的是用變量存儲(chǔ) id 加載新的選卡時(shí) 交換 id ,從而限制了打開的選項(xiàng)卡數(shù)量,如果不是一定要這個(gè)效果,建議不要頻繁的關(guān)閉和創(chuàng)建tabpanel,感興趣的朋友可以參考下哈2013-04-04關(guān)于viewport,Ext.panel和Ext.form.panel的關(guān)系
那個(gè)深入淺出ext作者比我還懶 viewport存放Ext.panel對(duì)象,其容器中的成員可以以borderlayout方式布局2009-05-05Extjs學(xué)習(xí)筆記之九 數(shù)據(jù)模型(上)
本文開始進(jìn)入Extjs最核心最優(yōu)秀的部分。2010-01-01Ext對(duì)基本類型的擴(kuò)展 ext,extjs,format
Ext對(duì)基本類型的擴(kuò)展 ext,extjs,format,學(xué)習(xí)extjs的朋友可以參考下。2010-12-12