Gird事件機(jī)制初級(jí)讀本
原文地址 文章日期:2006/09/25/
新版.32 的YUI-EXT包含了GIRD事件機(jī)制的重要升級(jí)。許多新事件現(xiàn)在可以用了,監(jiān)聽事件的機(jī)制也改變了(盡管它仍然向后兼容)。
偵聽事件的方法
鑒于 YAHOO.util.CustomEvent只提供簡單的訪問,Grid和相關(guān)的對(duì)象擴(kuò)展了新的方法來偵聽事件,這些事件你應(yīng)該是熟悉的。它們是:
- 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ù)簡介:
譯注:下面事件解釋以原文方式提供以便讀者準(zhǔn)確理解:
- 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 = ... // 這里注冊(cè)事件 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)文章
學(xué)習(xí)YUI.Ext 第六天--關(guān)于樹TreePanel(Part 1)
這篇文章主要介紹了學(xué)習(xí)YUI.Ext 第六天--關(guān)于樹TreePanel(Part 1)2007-03-03
解決extjs在firefox中關(guān)閉窗口再打開后iframe中js函數(shù)訪問不到的問題
最近做ext時(shí)遇到一個(gè)問題,在firefox中瀏覽ext應(yīng)用,加載后第一次打開一個(gè)嵌入iframe的Window時(shí),可以直接通過js代碼來執(zhí)行 iframe中的js函數(shù),但是如果將窗口關(guān)閉后重新再打開,將會(huì)拋出異常,說是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 操作是學(xué)習(xí) Javascript 很重點(diǎn)的一塊。YUI 提供了豐富的 DOM 操作接口,它們定義在 %BUILD%/dom/dom.js 中(封裝成 YAHOO.util.Dom)。由于 DOM 操作比較重要,我計(jì)劃將其分成幾個(gè) Part 分析。2008-03-03
Ext第一周 史上最強(qiáng)學(xué)習(xí)筆記---GridPanel(基礎(chǔ)篇)
我不想教各位新手什么高級(jí)技術(shù),因?yàn)槲乙苍谘芯浚皇窍虢檀蠹乙粋€(gè)思考的方向,能夠具有舉一反三的能力,能夠真正學(xué)會(huì)Ext和開始深入了解。2008-12-12
學(xué)習(xí)YUI.Ext 第七天--關(guān)于View&JSONView
學(xué)習(xí)YUI.Ext 第七天--關(guān)于View&JSONView...2007-03-03

