Ext 的代码演示
2008-02-15 10:20
337 查看
1 , 在ext 框架中,可以利用Ext.Panel 的autoLoad 属性来加载你需要的公共画面。比如你的logo,还有你的版权声明等等。
具体的使用方式是:
首先,在jsp或者html页面上给出一个位置来放置你准备放置的冬冬。
然后在js中间声明:
![](http://www.javaeye.com/images/icon_copy.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
var Footer = new Ext.Panel(...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
border:false,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
autoLoad: ...{url: 'template/Footer.html', callback: function()...{}, scope: this}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
});
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Footer.render('Footer');
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
var Footer = new Ext.Panel(...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
border:false,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
autoLoad: ...{url: 'template/Footer.html', callback: function()...{}, scope: this}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
});
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Footer.render('Footer');
autoLoad的三个参数的意思很明显,url表示需要装载的路径,callback表示在装载完毕之后干些什么,scope表示有效范围。
2, 在表单的提交过程当中,我们可以设置的地方。如下面的代码:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
var form = new Ext.form.FormPanel(...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
defaultType: 'textfield',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
labelAlign: 'right',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
title: '用户登陆',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
labelWidth: 120,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
frame: true,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
width: 500,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
autoHeight: true,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
waitMsgTarget: true, /**//* true的意思是说表单提交时的等待信息在这个表单之内显示,而不是弹出框 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
items: [...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fieldLabel: '用户名',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
name:"userAccount",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
id:"userAccount",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
allowBlank:false
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
},...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fieldLabel: '密码',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
inputType :'password',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
id:"passwd",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
name:"passwd"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}],
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
buttons: [...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
text: '登陆',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
handler: function()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
form.getForm().submit(...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
url:'../servlet/login', /**//* 表示表单提交的时候的路径。 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
waitMsg:'正在验证用户...', /**//* 表示提交过程中间的等待信息。 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
success: onLoginSuccess, /**//* 服务器返回正确的信息之后我们调用的方法。 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
failure: onFailure /**//* 服务器返回错误的信息之后我们调用的方法。 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
});
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
},...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
text: '取消',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
handler: function()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
win.hide();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
});
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//* 在用户校验失败的时候判断是否是服务器连接失败 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
var onFailure = function(form,action)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if(action.failureType=="connect")...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//* 在服务器返回了错误的信息或者是没有返回的时候,我们可以根据action.failureType来判断发生错误的大概原因,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
如果值为•connect•,那么表示是连接请求失败,•server•表示服务器端检查出了提交数据的错误,•client•表示客户端的数据异常 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Ext.Msg.alert('服务器异常', '服务器异常,请与管理员联系!');
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//* 用户校验成功之后的动作 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
var gotoUrl = function()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
window.location.href="ProjectManage.jsp";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
var onLoginSuccess = function(form,action)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
win.hide();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}.createSequence(gotoUrl,this)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//* createSequence这个方法还有一个姊妹方法,createInterceptor。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
她们分别表示在某某方法之后和某某方法之前执行某一个方法。其实就是js里面的aop。保证一个函数的调用顺序 *3, 有了下面的设定,上面讲的表单的提交之后,如果有数据校验失败的信息,在页面上将表现出更好的错误提示信息。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//* 设置提示消息的显示方式 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Ext.QuickTips.init();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Ext.form.Field.prototype.msgTarget = 'side';
4、讲一下gridPanel这个控件在创建之后都有哪些事件可以触发,以及我们如何来设置这样的触发事件。
察看以下gridPanel的源码,我们发现有如下的这么多的事件可以触发。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// raw events
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event click
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw click event for the entire grid. ------简单的事件描述,相信大家都看得懂,就不解释了。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e ---------------这个是框架会自动传入的参数,下面的一样。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"click", //------------- 这个是事件名称,下面的一样
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event dblclick
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw dblclick event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"dblclick",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event contextmenu
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw contextmenu event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"contextmenu",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event mousedown
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw mousedown event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"mousedown",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event mouseup
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw mouseup event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"mouseup",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event mouseover
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw mouseover event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"mouseover",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event mouseout
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw mouseout event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"mouseout",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event keypress
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw keypress event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"keypress",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event keydown
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw keydown event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"keydown",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// custom events
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event cellmousedown
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires before a cell is clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"cellmousedown",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event rowmousedown
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires before a row is clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"rowmousedown",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event headermousedown
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires before a header is clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"headermousedown",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event cellclick
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a cell is clicked.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The data for the cell is drawn from the {@link Ext.data.Record Record}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* for this row. To access the data in the listener function use the
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* following technique:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* <pre>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
<code>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
function(grid, rowIndex, columnIndex, e) {
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var record = grid.getStore().getAt(rowIndex); // Get the Record
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var fieldName = grid.getColumnModel().getDataIndex(columnIndex); // Get field name
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var data = record.get(fieldName);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
</code>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
</pre>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"cellclick",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event celldblclick
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a cell is double clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"celldblclick",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event rowclick
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a row is clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"rowclick",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event rowdblclick
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a row is double clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"rowdblclick",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event headerclick
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a header is clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"headerclick",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event headerdblclick
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a header cell is double clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"headerdblclick",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event rowcontextmenu
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a row is right clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"rowcontextmenu",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event cellcontextmenu
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a cell is right clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} cellIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"cellcontextmenu",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event headercontextmenu
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a header is right clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"headercontextmenu",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event bodyscroll
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when the body element is scrolled
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} scrollLeft
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} scrollTop
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"bodyscroll",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event columnresize
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when the user resizes a column
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} newSize
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"columnresize",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event columnmove
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when the user moves a column
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} oldIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} newIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"columnmove",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event sortchange
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when the grid's store sort changes
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Object} sortInfo An object with the keys field and direction
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"sortchange"
然后是我们怎么样来设置这些事件。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//* 设置grid的双击事件 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
grid.on("rowdblclick" , function(grid)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var row = grid.getSelectionModel().getSelected();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
alert(row.get("title"))
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
});
5,由DWRProxy来使用dwr的数据
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//* 由dwr提供的数据创建适合grid使用的数据 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
var recordType = Ext.data.Record.create([ //给出一个后台数据的结构
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{name: "id", type: "int"},
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{name: "title", type: "string"},
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{name: "content", type: "string"},
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{name: "name", mapping:"author.name", type: "string"},
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{name: "email", mapping:"author.email", type: "string"}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
]);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
var ds = new Ext.data.Store(...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
proxy: new Ext.data.DWRProxy(testdwr.getItems, true),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
reader: new Ext.data.ListRangeReader(...{id:"id",totalProperty:'totalSize'},recordType),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
remoteSort: true
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
});
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
ds.load(...{params:...{start:0, limit:10}, arg:[]}); //用于分页的信息以及其他信息都可以在这儿设置参数。
具体的使用方式是:
首先,在jsp或者html页面上给出一个位置来放置你准备放置的冬冬。
然后在js中间声明:
![](http://www.javaeye.com/images/icon_copy.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
var Footer = new Ext.Panel(...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
border:false,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
autoLoad: ...{url: 'template/Footer.html', callback: function()...{}, scope: this}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
});
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Footer.render('Footer');
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
var Footer = new Ext.Panel(...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
border:false,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
autoLoad: ...{url: 'template/Footer.html', callback: function()...{}, scope: this}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
});
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Footer.render('Footer');
autoLoad的三个参数的意思很明显,url表示需要装载的路径,callback表示在装载完毕之后干些什么,scope表示有效范围。
2, 在表单的提交过程当中,我们可以设置的地方。如下面的代码:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
var form = new Ext.form.FormPanel(...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
defaultType: 'textfield',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
labelAlign: 'right',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
title: '用户登陆',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
labelWidth: 120,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
frame: true,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
width: 500,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
autoHeight: true,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
waitMsgTarget: true, /**//* true的意思是说表单提交时的等待信息在这个表单之内显示,而不是弹出框 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
items: [...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fieldLabel: '用户名',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
name:"userAccount",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
id:"userAccount",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
allowBlank:false
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
},...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
fieldLabel: '密码',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
inputType :'password',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
id:"passwd",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
name:"passwd"
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}],
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
buttons: [...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
text: '登陆',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
handler: function()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
form.getForm().submit(...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
url:'../servlet/login', /**//* 表示表单提交的时候的路径。 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
waitMsg:'正在验证用户...', /**//* 表示提交过程中间的等待信息。 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
success: onLoginSuccess, /**//* 服务器返回正确的信息之后我们调用的方法。 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
failure: onFailure /**//* 服务器返回错误的信息之后我们调用的方法。 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
});
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
},...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
text: '取消',
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
handler: function()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
win.hide();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
});
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//* 在用户校验失败的时候判断是否是服务器连接失败 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
var onFailure = function(form,action)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if(action.failureType=="connect")...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
/**//* 在服务器返回了错误的信息或者是没有返回的时候,我们可以根据action.failureType来判断发生错误的大概原因,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
如果值为•connect•,那么表示是连接请求失败,•server•表示服务器端检查出了提交数据的错误,•client•表示客户端的数据异常 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Ext.Msg.alert('服务器异常', '服务器异常,请与管理员联系!');
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//* 用户校验成功之后的动作 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
var gotoUrl = function()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
window.location.href="ProjectManage.jsp";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
var onLoginSuccess = function(form,action)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
win.hide();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}.createSequence(gotoUrl,this)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//* createSequence这个方法还有一个姊妹方法,createInterceptor。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
她们分别表示在某某方法之后和某某方法之前执行某一个方法。其实就是js里面的aop。保证一个函数的调用顺序 *3, 有了下面的设定,上面讲的表单的提交之后,如果有数据校验失败的信息,在页面上将表现出更好的错误提示信息。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//* 设置提示消息的显示方式 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Ext.QuickTips.init();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Ext.form.Field.prototype.msgTarget = 'side';
4、讲一下gridPanel这个控件在创建之后都有哪些事件可以触发,以及我们如何来设置这样的触发事件。
察看以下gridPanel的源码,我们发现有如下的这么多的事件可以触发。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// raw events
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event click
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw click event for the entire grid. ------简单的事件描述,相信大家都看得懂,就不解释了。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e ---------------这个是框架会自动传入的参数,下面的一样。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"click", //------------- 这个是事件名称,下面的一样
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event dblclick
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw dblclick event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"dblclick",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event contextmenu
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw contextmenu event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"contextmenu",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event mousedown
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw mousedown event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"mousedown",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event mouseup
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw mouseup event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"mouseup",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event mouseover
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw mouseover event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"mouseover",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event mouseout
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw mouseout event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"mouseout",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event keypress
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw keypress event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"keypress",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event keydown
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The raw keydown event for the entire grid.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"keydown",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// custom events
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event cellmousedown
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires before a cell is clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"cellmousedown",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event rowmousedown
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires before a row is clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"rowmousedown",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event headermousedown
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires before a header is clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"headermousedown",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event cellclick
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a cell is clicked.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* The data for the cell is drawn from the {@link Ext.data.Record Record}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* for this row. To access the data in the listener function use the
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* following technique:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* <pre>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
<code>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
function(grid, rowIndex, columnIndex, e) {
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var record = grid.getStore().getAt(rowIndex); // Get the Record
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var fieldName = grid.getColumnModel().getDataIndex(columnIndex); // Get field name
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var data = record.get(fieldName);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
</code>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
</pre>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"cellclick",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event celldblclick
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a cell is double clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"celldblclick",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event rowclick
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a row is clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"rowclick",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event rowdblclick
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a row is double clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"rowdblclick",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event headerclick
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a header is clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"headerclick",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event headerdblclick
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a header cell is double clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"headerdblclick",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event rowcontextmenu
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a row is right clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"rowcontextmenu",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event cellcontextmenu
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a cell is right clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} rowIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} cellIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"cellcontextmenu",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event headercontextmenu
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when a header is right clicked
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Ext.EventObject} e
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"headercontextmenu",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event bodyscroll
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when the body element is scrolled
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} scrollLeft
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} scrollTop
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"bodyscroll",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event columnresize
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when the user resizes a column
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} columnIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} newSize
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"columnresize",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event columnmove
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when the user moves a column
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} oldIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Number} newIndex
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"columnmove",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//**
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @event sortchange
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Fires when the grid's store sort changes
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Grid} this
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* @param {Object} sortInfo An object with the keys field and direction
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
"sortchange"
然后是我们怎么样来设置这些事件。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//* 设置grid的双击事件 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
grid.on("rowdblclick" , function(grid)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var row = grid.getSelectionModel().getSelected();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
alert(row.get("title"))
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
});
5,由DWRProxy来使用dwr的数据
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//* 由dwr提供的数据创建适合grid使用的数据 */
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
var recordType = Ext.data.Record.create([ //给出一个后台数据的结构
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{name: "id", type: "int"},
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{name: "title", type: "string"},
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{name: "content", type: "string"},
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{name: "name", mapping:"author.name", type: "string"},
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{name: "email", mapping:"author.email", type: "string"}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
]);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
var ds = new Ext.data.Store(...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
proxy: new Ext.data.DWRProxy(testdwr.getItems, true),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
reader: new Ext.data.ListRangeReader(...{id:"id",totalProperty:'totalSize'},recordType),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
remoteSort: true
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
});
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
ds.load(...{params:...{start:0, limit:10}, arg:[]}); //用于分页的信息以及其他信息都可以在这儿设置参数。
相关文章推荐
- ext-2.0扩展多选下拉框(代码及演示)
- ext-2.0扩展多选下拉框(代码及演示)
- ext-2.0扩展树形下拉框(代码及演示)
- ext-2.0扩展多选下拉框(代码及演示)
- ext-2.0扩展多选下拉框(代码及演示)
- ext-2.0扩展多选下拉框(代码及演示)
- ext-2.0扩展树形下拉框(代码及演示)
- 窗口的各种传值在线演示示例(示例都使用的page参数,内容页中的代码最好打开相应的内容页查看)
- lucene 4.3 通过TokenStream显示分词代码演示
- ASP.NET Web开发框架之五 设计时支持,代码生成,数据字典 ExtAspNet控件扩展
- kalman 滤波 演示与opencv代码
- Duang~Duang~Duang 还在使用jsfiddle和jsbin做在线前端代码展示和演示吗? 试试更强大的在线代码分享工具吧!
- 多线程问题,三个线程轮流进行,每个线程进行n次操作,共执行n*n*3次操作。本代码用三军攻击做演示,通俗易懂。
- ext中有关继承的实现的关键代码如下:(Ext.js中)
- 脚本演示的天堂:共享一个可以提供代码示例和运行结果的非常不错的网站
- asp.net 预编译后代码的反编译成源码(演示:鹏为CRM E4版本)
- 天气查询接口演示代码
- Javascript的各种节点操作实例演示代码
- 【技术分享】TP-Link WR841N路由器任意代码执行漏洞分析(附演示视频)
- java集合框架代码演示demo