Gird事件機制初級讀本
原文地址 文章日期:2006/09/25/
新版.32 的YUI-EXT包含了GIRD事件機制的重要升級。許多新事件現(xiàn)在可以用了,監(jiān)聽事件的機制也改變了(盡管它仍然向后兼容)。
偵聽事件的方法
鑒于 YAHOO.util.CustomEvent只提供簡單的訪問,Grid和相關(guān)的對象擴展了新的方法來偵聽事件,這些事件你應該是熟悉的。它們是:
- addListener(eventName, fn, scope, override) - "eventName" should be one of the events defined below. "fn" is the function to call when the event occurs. "scope" is an optional object providing the scope (this) of the function. "override" is whether or not to apply that scope and is only there for backwards compatibility.
- removeListener(eventName, fn, scope) -移除前先提交的事件偵聽
- on(eventName, fn, scope, override) - addListener 快捷方式
這些方法與YAHOO.uitl.Event一樣,有相同的署名(signatures)。
onRowSelect事件的偵聽:
var sm = grid.getSelectionModel();
sm.addListener('rowselect', myHandler);
這是GIRD暴露事件的列表和參數(shù)簡介:
譯注:下面事件解釋以原文方式提供以便讀者準確理解:
- cellclick - (this, rowIndex, columnIndex, e) - Fires when a cell is clicked
- celldblclick - (this, rowIndex, columnIndex, e) - Fires when a cell is double clicked
- rowclick - (this, rowIndex, e) - Fires when a row is clicked
- rowdblclick - (this, rowIndex, e) - Fires when a row is double clicked
- headerclick - (this, columnIndex, e) - Fires when a header is clicked
- rowcontextmenu - (this, rowIndex, e) - Fires when a row is right clicked
- headercontextmenu - (this, columnIndex, e) - Fires when a header is right clicked
- beforeedit - (this, rowIndex, columnIndex, e) - Fires just before editing is started on a cell
- afteredit - (this, rowIndex, columnIndex, e) - Fires immediately after a cell is edited
- bodyscroll - (scrollLeft, scrollTop) - Fires when the grid's body is scrolled
- columnresize - (columnIndex, newSize) Fires when the user resizes a column.
- startdrag - (this, dd, e) - Fires when row(s) start being dragged
- enddrag - (this, dd, e) - Fires when a drag operation is complete
- dragdrop - (this, dd, targetId, e) - Fires when dragged row(s) are dropped on a valid DD target
- dragover - (this, dd, targetId, e) Fires while row(s) are being dragged. "targetId" is the id of the Yahoo.util.DD object the selected rows are being dragged over.
- dragenter - (this, dd, targetId, e) - Fires when the dragged row(s) first cross another DD target while being dragged
- dragout - (this, dd, targetId, e) - Fires when the dragged row(s) leave another DD target while being dragged
Gird事件的例子
function onCellClick(grid, rowIndex, colIndex, e){
alert('Cell at row ' + rowIndex + ', column ' + colIndex + ' was clicked!');
}
var grid = ... // 這里注冊事件 grid.addListener('cellclick', onCellClick);
- click
- dblclick
- mousedown
- mouseup
- mouseover
- mouseout
- keypress
- keydown
var img = getEl('loading-indicator'); var dm = grid.getDataModel(); dm.addListener('beforeload', img.show, img, true); dm.addListener('load', img.hide, img, true);相關(guān)文章
學習YUI.Ext 第六天--關(guān)于樹TreePanel(Part 1)
這篇文章主要介紹了學習YUI.Ext 第六天--關(guān)于樹TreePanel(Part 1)2007-03-03
解決extjs在firefox中關(guān)閉窗口再打開后iframe中js函數(shù)訪問不到的問題
最近做ext時遇到一個問題,在firefox中瀏覽ext應用,加載后第一次打開一個嵌入iframe的Window時,可以直接通過js代碼來執(zhí)行 iframe中的js函數(shù),但是如果將窗口關(guān)閉后重新再打開,將會拋出異常,說是funcName is not a function2008-11-11
為Yahoo! UI Extensions Grid增加內(nèi)置的可編輯器
為Yahoo! UI Extensions Grid增加內(nèi)置的可編輯器...2007-03-03
YUI 讀碼日記之 YAHOO.util.Dom - Part.1
DOM 操作是學習 Javascript 很重點的一塊。YUI 提供了豐富的 DOM 操作接口,它們定義在 %BUILD%/dom/dom.js 中(封裝成 YAHOO.util.Dom)。由于 DOM 操作比較重要,我計劃將其分成幾個 Part 分析。2008-03-03
Ext第一周 史上最強學習筆記---GridPanel(基礎(chǔ)篇)
我不想教各位新手什么高級技術(shù),因為我也在研究,只是想教大家一個思考的方向,能夠具有舉一反三的能力,能夠真正學會Ext和開始深入了解。2008-12-12
學習YUI.Ext 第七天--關(guān)于View&JSONView
學習YUI.Ext 第七天--關(guān)于View&JSONView...2007-03-03
今天頭兒分了一個項目的一張頁面給我做!要修改幾個問題!一個按F5局部刷新Grid網(wǎng)格中數(shù)據(jù)!第二個:網(wǎng)格一些信息是雙擊打開就已經(jīng)讀?。?/div> 2010-09-09最新評論

