Gird事件机制初级读本

2016-02-19 10:20 3 1 收藏

人生本是一个不断学习的过程,在这个过程中,图老师就是你们的好帮手,下面分享的Gird事件机制初级读本懂设计的网友们快点来了解吧!

【 tulaoshi.com - Web开发 】

原文地址 文章日期:2006/09/25/

 新版.32 的YUI-EXT包含了GIRD事件机制的重要升级。许多新事件现在可以用了,监听事件的机制也改变了(尽管它仍然向后兼容)。

侦听事件的方法

鉴于 YAHOO.util.CustomEvent只提供简单的访问,Grid和相关的对象扩展了新的方法来侦听事件,这些事件你应该是熟悉的。它们是:

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)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暴露事件的列表和参数简介:

- "this" 指的是Grid对象; - "e" 指的是 YAHOO.ext.EventObject (常规化事件对象) ,除了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事件的例子

(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)
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

来源:http://www.tulaoshi.com/n/20160219/1594266.html

延伸阅读
标签: Web开发
原文地址 文章日期:2006/09/04 新组件Gird包含了许多的类和继承方法。如果读者不是太熟悉的面向对象开发的话,可能会对一个变量如何从某个类得到继承的方法感到困惑,用起GIRD来感到困难。在YAHOO.ext.gird包中,大多数类是设计成为“即插即用plug and play”的,可扩展的extended和可自定义的customized,能以最小量的代码插入轻松到web程序中...
标签: Web开发
原文地址 文章日期:2006/9/26 新版的GIRD可以支持远程数据了。分页和远程排序的设置是通俗易懂的,另外一些常用的自定义的参数我会在这篇贴子中说明一下。新论坛的界面(在建设中)就是一个分页和远程排序的好例子,而本文的代码均来自那个例子。 新方法和属性 利用LoadableDatatModel对象(XMLDataModel和JSONDataModel的父类)实现分...
标签: 怀孕
饮食 春节期间难免有很多大鱼大肉,所以早孕期的准妈妈们最好给自己单独准备一些清淡而营养丰富的食品,多进食蔬菜水果。 中孕期可以随意进食,但注意不要暴饮暴食,不要吃太多的主食或甜食,否则会使自己增加太多的体重而宝宝增长则不多。 晚孕期进食过多会导致上腹部不适,应该少量多次进食。 我们在过...
标签: Web开发
原文在这里 文章日期:2006-9-2 代码在这里 Q:unknown {content: ''}Q:unknown {content: ''}.ygrid-cell-text {PADDING-RIGHT: 5px; DISPLAY: block; PADDING-LEFT: 5px; PADDING-BOTTOM: 3px; FONT: 8pt arial; OVERFLOW: hidden; PADDING-TOP: 3px; WHITE-SPACE: nowrap}.ygrid-col {DISPLAY: block; OVERFLOW: hidden; BORDER-LEFT: #f...
标签: Web开发
1、基本概念 JavaScript 是基于对象(object-based)的语言。这与Java不同,Java是面向对象的语言。而基于对象的基本特征,就是采用事件驱动(event-driven)。它是在用形界面的环境下,使得一切输入变化简单化。通常鼠标或热键的动作我们称之为事件(Event),而由鼠标或热键引发的一连串程序的动作,称之为事件驱动(Event Driver)。...

经验教程

722

收藏

59
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部