当前位置: 58彩票app下载 > 58彩票网络 > 正文

Gird事件机制初级读本

时间:2019-09-23 01:18来源:58彩票网络
原著地址作品日期:二零零五/09/25 /  新版.32的YUI-EXT满含了GIRAV4D事件机制的重要晋级。相当多新事件现在得以用了,监听事件的机制也改造了(即便它仍旧向后杰出)。 侦听事件的艺

原著地址 作品日期:二零零五/09/25/

 新版.32 的YUI-EXT满含了GIRAV4D事件机制的重要晋级。相当多新事件现在得以用了,监听事件的机制也改造了(即便它仍旧向后杰出)。

侦听事件的艺术

鉴于 YAHOO.util.Custom伊芙nt只提供轻松的拜见,Grid和血脉相通的靶子扩展了新的办法来侦听事件,那个事件你应当是相当熟知的。它们是:

  • 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);

那是GI帕拉梅拉D揭发事件的列表和参数简单介绍:

- "this" 指的是Grid对象;

- "e" 指的是 YAHOO.ext.伊夫ntObject (常规化事件指标) ,除了Drag & Drop对象是专门的学业浏览器事件目的。

- "dd" 指的是Grid的YAHOO.ext.GridDD对象。

译注:下边事件表明以原著格局提供以便读者正确精通:

  • 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);

 

普通Grid事件

Since there is no way to envision everything you may want to do with the grid, I've also exposed direct access to many of the grid's raw events. All of these events pass one parameter to their handler: "e" a YAHOO.ext.EventObject.

  • click
  • dblclick
  • mousedown
  • mouseup
  • mouseover
  • mouseout
  • keypress
  • keydown

LoadableDataModel (from which XMLDataModel and JSONDataModel are derived) picked up a useful new event:

beforeload - Fires right before the model starts fetching remote data.

You could use this event combined with the load event to hide/show a loading indicator.

var img = getEl('loading-indicator'); var dm = grid.getDataModel(); dm.addListener('beforeload', img.show, img, true); dm.addListener('load', img.hide, img, true);

Hopefully this can get you started with the new event system. If you have any questions, feel free to post in the Help Forum and I will help you out.

Jack

编辑:58彩票网络 本文来源:Gird事件机制初级读本

关键词: