Context Menu"
(→I18N) |
m |
||
Line 1: | Line 1: | ||
− | |||
− | |||
{{ZKSpreadsheetEssentialsPageHeader}} | {{ZKSpreadsheetEssentialsPageHeader}} | ||
Line 6: | Line 4: | ||
===Purpose=== | ===Purpose=== | ||
− | ZK Spreadsheet supports various context | + | ZK Spreadsheet supports various context menus to support row/column/cell actions for individual or selected number of cells. |
===Show Context Menu=== | ===Show Context Menu=== | ||
Line 15: | Line 13: | ||
[[File:ZKSsEss_Spreadsheet_Toolbar_rowContextMenu.png]] | [[File:ZKSsEss_Spreadsheet_Toolbar_rowContextMenu.png]] | ||
− | + | For <b>row context menu</b> use [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Action_Handler ActionHandler] for each menuitem. By default, <b>ActionHandler</b> does nothing when users clicks on '''Paste Special''', '''Format Cell''' and '''Row Height''', to use customized <b>ActionHandler</b> <refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Action_Handler here]. | |
=====Paste Special===== | =====Paste Special===== | ||
Refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Paste_Special here] | Refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Paste_Special here] | ||
=====Format Cell===== | =====Format Cell===== | ||
− | + | By default, <b>ActionHandler</b> does nothing when users clicks the button, developer are able to override <javadoc directory="zss" method="doFormatCell">org.zkoss.zss.ui.sys.ActionHandler</javadoc> | |
<source lang="java" high="2"> | <source lang="java" high="2"> | ||
Line 36: | Line 34: | ||
=====Row Height===== | =====Row Height===== | ||
− | + | By default, <b>ActionHandler</b> does nothing when users clicks the button, developers are able to override <javadoc directory="zss" method="doRowHeight">org.zkoss.zss.ui.sys.ActionHandler</javadoc> | |
<source lang="java" high="2"> | <source lang="java" high="2"> | ||
Line 55: | Line 53: | ||
[[File:ZKSsEss_Spreadsheet_Toolbar_columnContextMenu.png]] | [[File:ZKSsEss_Spreadsheet_Toolbar_columnContextMenu.png]] | ||
− | + | For column context menu use [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Action_Handler ActionHandler] for each button/menuitem. By default, <b>ActionHandler</b> does nothing when users clicks '''Paste Special''', '''Format Cell''' and '''Column Width''', to use customized <b>ActionHandler</b> refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Action_Handler here] . | |
=====Paste Special===== | =====Paste Special===== | ||
Line 62: | Line 60: | ||
Refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Context_Menu#Format_Cell here] | Refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Context_Menu#Format_Cell here] | ||
=====Column Width===== | =====Column Width===== | ||
− | + | By default, <b>ActionHandler</b> does nothing when user click the button, developers are able to override <javadoc directory="zss" method="doColumnWidth">org.zkoss.zss.ui.sys.ActionHandler</javadoc> | |
<source lang="java" high="2"> | <source lang="java" high="2"> | ||
Line 81: | Line 79: | ||
[[File:ZKSsEss_Spreadsheet_Toolbar_cellContextMenu.png]] | [[File:ZKSsEss_Spreadsheet_Toolbar_cellContextMenu.png]] | ||
− | + | For cell context menu, use [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Action_Handler ActionHandler] for each button/menuitem. By default, <b>ActionHandler</b> does nothing when users click '''Paste Special''', '''Format Cell''' and '''Hyperlink''', to use customized <b>ActionHandler</b> refer to [http://books.zkoss.org/wiki/ZK_Spreadsheet_Essentials/Working_with_ZK_Spreadsheet/Configure_and_Control_ZK_Spreadsheet/Toolbar#Action_Handler here]. | |
=====Paste Special===== | =====Paste Special===== | ||
Line 91: | Line 89: | ||
====I18N==== | ====I18N==== | ||
− | Each menuitem | + | Each menuitem maps to a key, developers can browse all I18 keys by <javadoc directory="zss" method="getLabelKeys">org.zkoss.zss.ui.Action</javadoc> |
− | Here | + | Here are the partial keys for context menu |
{| border="1" | {| border="1" | ||
|- | |- | ||
Line 158: | Line 156: | ||
===ZUML=== | ===ZUML=== | ||
− | Here is a | + | Here is an example of a ZUL file |
<source lang="xml" high="4"> | <source lang="xml" high="4"> | ||
Line 175: | Line 173: | ||
===Composer=== | ===Composer=== | ||
− | The composer | + | The composer uses <javadoc directory="zss" method="setShowContextMenu">org.zkoss.zss.ui.Spreadsheet</javadoc> to show or hide context menu. |
<source lang="java" high="3"> | <source lang="java" high="3"> | ||
public void onClick$toggleContextMenu() { | public void onClick$toggleContextMenu() { |
Revision as of 06:37, 17 April 2012
Purpose
ZK Spreadsheet supports various context menus to support row/column/cell actions for individual or selected number of cells.
Show Context Menu
Use Spreadsheet.setShowContextMenu to show context menu.
Row
For row context menu use ActionHandler for each menuitem. By default, ActionHandler does nothing when users clicks on Paste Special, Format Cell and Row Height, to use customized ActionHandler <refer to here.
Paste Special
Refer to here
Format Cell
By default, ActionHandler does nothing when users clicks the button, developer are able to 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
By default, ActionHandler does nothing when users clicks the button, developers are able to 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
For column context menu use ActionHandler for each button/menuitem. By default, ActionHandler does nothing when users clicks Paste Special, Format Cell and Column Width, to use customized ActionHandler refer to here .
Paste Special
Refer to here
Format Cell
Refer to here
Column Width
By default, ActionHandler does nothing when user click the button, developers are able to 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
For cell context menu, use ActionHandler for each button/menuitem. By default, ActionHandler does nothing when users click Paste Special, Format Cell and Hyperlink, to use customized ActionHandler refer to here.
Paste Special
Refer to here
Format Cell
Refer to here
Hyperlink
Refer to here
I18N
Each menuitem maps to a key, developers can browse all I18 keys by Action.getLabelKeys
Here are the 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 an example of a 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 uses 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
Version | Date | Content |
---|---|---|
2.3.0 | April, 2012 | Context Menu |
All source code listed in this book is at Github.