Two Methods of right-click the ExtJs grid row menu

Source: Internet
Author: User

Below: method 1
Copy codeThe Code is as follows:
<% @ 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> No title page </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: "No.", width: 50 }),
{Header: "No.", dataIndex: "ID", width: 10, hidden: true },
{Header: "title", dataIndex: "TypeCName", width: 100, editor: new Ext. form. TextField ()},
{Header: "English name", dataIndex: "TypeEName", width: 100, editor: new Ext. form. TextField ()},
{Header: "status", dataIndex: "DelFlag", width: 100, renderer: function (value) {if (value = false) {return "display ";} else {return "hide ";}}},
{Header: "add date", dataIndex: "AddDate", width: 100, renderer: Ext. util. Format. dateRenderer ('y, m, dday ')}
]);
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: "No data display ",
DisplayMsg: "displays {2} data records from {0} to {1} data records ",
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: ' Ext2.2 new feature series-right-click menu ',
Bbar: pagingBar
});
Grid. on ("rowcontextmenu", function (grid, rowIndex, e)
{
E. preventDefault (); if (rowIndex <0) {return ;}
Var treeMenu = new Ext. menu. Menu
([
{Xtype: "button", text: "add", icon: "Images/Icons/button/add.gif", pressed: true, handler: function (){}},
{Xtype: "button", text: "edit", icon: "Images/Icons/button/delete.gif", pressed: true, handler: function (){}},
{Xtype: "button", text: "hide", icon: "Images/Icons/arrow-down.gif", pressed: true, handler: function (){}},
{Xtype: "button", text: "display", icon: "Images/Icons/arrow-up.gif", pressed: true, handler: function (){}},
{Xtype: "button", text: "delete", icon: "Images/Icons/button/cross.gif", pressed: true, handler: function (){}},
{Xtype: "button", text: "Upload image", 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>

Right-click Extjs grid and choose method 2.
Copy codeThe Code is as follows:
Grid. on ("rowcontextmenu", function (grid, rowIndex, e ){
E. preventDefault ();
If (rowIndex <0) {return ;}
Var treeMenu = new Ext. menu. Menu
([
{
Xtype :"",
Text: "details ",
IconCls: 'Context-dog ',
Pressed: false,
Handler: function (){
// Obtain row data
Var record = grid. getStore (). getAt (rowIndex );
// Open_receive_detailWindow (record. data. smsIndex );
Alert (record. data. company );
// Record. data. taskId
}
},{
Xtype :"",
Text: "delete ",
IconCls: 'Context-cat ',
Pressed: false,
Handler: function (){
// Obtain row data
Var record = grid. getStore (). getAt (rowIndex );
Alert (record. data. company );
}
}
]);
TreeMenu. showAt (e. getXY ());
});

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.