Context Menu

From Documentation

WarningTriangle-32x32.png This page is under construction, so we cannot guarantee the accuracy of the content!



Purpose

ZK Spreadsheet supports various context menu to perform action.

Show Context Menu

Use Spreadsheet.setShowContextMenu to show context menu.

Row

ZKSsEss Spreadsheet Toolbar rowContextMenu.png

Row context menu use ActionHandler for each menuitem. The default ActionHandler does nothing when user click Paste Special, Format Cell and Row Height, refer to here to use customized ActionHandler.

Paste Special

Refer to here

Format Cell

The default ActionHandler does nothing when user click the button, developer could override ActionHandler.doFormatCell

	@Override
	public void doFormatCell(Rect selection) {
		Spreadsheet spreadsheet = getSpreadsheet();
		if (spreadsheet.getBook() != null && isValidSelection(selection)) {
			FormatDialog dialog = new FormatDialog(selection);
			//omit	
		}
	}

Refer to sample code formatDialog.zul and CustomizedActionHandler.java

Row Height

The default ActionHandler does nothing when user click the button, developer could override ActionHandler.doRowHeight

	@Override
	public void doRowHeight(Rect selection) {
		Spreadsheet spreadsheet = getSpreadsheet();
		if (spreadsheet.getBook() != null && isValidSelection(selection)) {
			HeaderSizeDialog dialog = new HeaderSizeDialog("row", selection);
			//omit	
		}
	}

Refer to sample code headerSizeDialog.zul and CustomizedActionHandler.java

Column

ZKSsEss Spreadsheet Toolbar columnContextMenu.png

Column context menu use ActionHandler for each button/menuitem. The default ActionHandler does nothing when user click Paste Special, Format Cell and Column Width, refer to here to use customized ActionHandler.

Paste Special

Refer to here

Format Cell

Refer to here

Column Width

The default ActionHandler does nothing when user click the button, developer could override ActionHandler.doColumnWidth

	@Override
	public void doColumnWidth(Rect selection) {
		Spreadsheet spreadsheet = getSpreadsheet();
		if (spreadsheet.getBook() != null && isValidSelection(selection)) {
			HeaderSizeDialog dialog = new HeaderSizeDialog("column", selection);
			//omit
		}
	}

Refer to sample code headerSizeDialog.zul and CustomizedActionHandler.java

Cell

ZKSsEss Spreadsheet Toolbar cellContextMenu.png

Cell context menu use ActionHandler for each button/menuitem. The default ActionHandler does nothing when user click Paste Special, Format Cell and Hyperlink, , refer to here to use customized ActionHandler.

Paste Special

Refer to here

Format Cell

Refer to here

Hyperlink

Refer to here

I18N

Each menuitem map to a key, developer could browse all I18 keys by Action.getLabelKeys

Here is partial keys for context menu

Action I18 Key
Cut zss.cut
Copy zss.copy
Paste Special zss.pasteSpecial
Insert zss.insert
Insert Rows zss.insertSheetRow
Insert Columns zss.insertSheetColumn
Shift Cell Right zss.shiftCellRight
Shift Cell Down zss.shiftCellDown
Delete zss.del
Delete Rows zss.deleteSheetRow
Delete Columns zss.deleteSheetColumn
Shift Cell Left zss.shiftCellLeft
Shift Cell Up zss.shiftCellUp
Clear Context zss.clearContent
Format Cell zss.formatCell
Row Height zss.rowHeight
Column Width zss.columnWidth
Hide Row zss.hideRow
Unhide Row zss.unhideRow
Hide Column zss.hideColumn
Unhide Column zss.unhideColumn
Filter zss.filter
Reapply Filter zss.reapplyFilter
Sort zss.sort
Sort Ascending zss.sortAscending
Sort Descending zss.sortDescending
Custom Sort zss.customSort
Hyperlink zss.hyperlink

Refer to sample i3-label.properties

ZUML

Here is a sample example ZUL file

<zk>
	<window vflex="1" width="100%" apply="org.zkoss.zssessentials.config.ContextMenuComposer">
		<button id="toggleContextMenu" label="Toggle Context Menu"/>
		<spreadsheet showContextMenu="true"
			id="ss" vflex="true" width="100%"
			src="/WEB-INF/excel/config/ZSS-demo_sample.xlsx" maxcolumns="40" maxrows="200"
			></spreadsheet>
	</window>
</zk>

View complete source of ZUML contextMenu.zul

Composer

The composer use Spreadsheet.setShowContextMenu to show or hide context menu.

	public void onClick$toggleContextMenu() {
		boolean toggle = !spreadsheet.isShowContextMenu();
		spreadsheet.setShowContextMenu(toggle);
	}

See the full source code for Composer here

Version History

Last Update : 2012/04/09


Version Date Content
2.3.0 April, 2012 Context Menu
     


All source code listed in this book is at Github.


Last Update : 2012/04/09

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