Listen to Cell Changes and Action

From Documentation


Listen to Cell Changes and Action



Users can write cell change event listeners for those cases when cells' values or styles are changed.

Purpose

Implement cell change event listeners for cell contents changes.

Cell Change Event

There are one cell change event. onCellChange - This event is fired when user change the contents or styles of a selection directly or indirectly. Event listeners are provided with CellSelectionEvent in the event listener.

Registering Cell Events

Cell change event 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 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.

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/12/02


Version Date Content
     


All source code listed in this book is at Github.


Last Update : 2010/12/02

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