Listen to Cell Changes and Action

From Documentation
Revision as of 04:51, 19 November 2010 by Henrichen (talk | contribs)


Listen to Cell Changes and Action



Users can write cell change event listeners for those cases when cells' contents is changed.

Purpose

Implement cell change event listeners for any cell contents changes.

Cell Change events

There are on cell change event.

  • onCellChange - This event is fired whenever cell's value or associated style has changed. Event listeners are provided with org.zkoss.zss.ui.event.CellEvent in the event listener.

Registering Cell Events

Mouse events can be registered to ZK Spreadsheet either by calling AbstractComponent.addEventListener(String, EventListener) or by using ZK MVC way i.e. using naming convention of <event-name>$<component-id>. Here is an example shown using first way

...
ss.addEventListener(org.zkoss.zss.ui.event.Events.ON_CELL_CHANGE,
		new EventListener() {
			public void onEvent(Event event) throws Exception {
				doCellChangeEvent((CellEvent) event);
			}
		});
...

Note: All ZK Spreadsheet supported mouse events have a corresponding static constants declared in org.zkoss.zss.ui.event.Events class. For example for onCellChange event there is org.zkoss.zss.ui.event.Events.ON_CELL_CHANGE and so on.

Here is an example shown using second way

...
public void onCellChange$ss(CellEvent event) {
	doCellChangeEvent(Ranges.range(event.getSheet(), event.getRow(), event.getColumn()));
}
...

Version History

Last Update : 2010/11/19


Version Date Content
     


All source code listed in this book is at Github.


Last Update : 2010/11/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.