Handling Events

From Documentation
⧼coll-notfound_msg⧽

Return to Documentation.




When a user interacts with Spreadsheet like clicking or editing, these actions trigger events being sent to the server. We can implement our business logic in a event listener, a method in a controller, to listen events we are interested in. When the event we listen is triggered, our special business logic is performed. This mechanism helps you customize Spreadsheet furthermore to fulfill your business needs.

ZK Spreadsheet supports numerous events such as mouse events, key events, selection events, editing events and hyperlink events. You can listen to these events to apply customized function upon your business requirement. For example by listening to editing events such as onStartEditing and onStopEditing you can control which cell the user can edit, what is entered/edited and possibly apply some styling or value transformation once the editing is stopped. Similarly, you can also listen to mouse events such as onCellClick or onCellRightClick and update other ZK components or pop up a menu.

In following sections, we will present examples of listening events and they all use SelectorComposer which provides a quite simple way to listen a event, just apply @Listen on a method and specify listening event names and target components. (For complete explanation, please refer to ZK Developer's Reference/MVC/Controller/Wire Event Listeners). A typical sample is like:

public class EventsComposer extends SelectorComposer<Component>{
	//other codes...

	@Listen("onStartEditing = spreadsheet")
	public void onStartEditing(StartEditingEvent event){
		//perform your business logic
	}
}
  • Line : All event name can be found in <javadoc>