Disable Functions"

From Documentation
m (correct highlight (via JWB))
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{ZKSpreadsheetEssentials3PageHeader}}
 +
 +
 +
 +
 
Spreadsheet provides API to disable its functions. The API can be very useful when you implement your user permission features. In the example application below, since we disable all sheet related functions except one, you can see the corresponding menu items are disabled (in grey color).
 
Spreadsheet provides API to disable its functions. The API can be very useful when you implement your user permission features. In the example application below, since we disable all sheet related functions except one, you can see the corresponding menu items are disabled (in grey color).
 
[[File:zss-essentials-disableFunctions.png | center]]
 
[[File:zss-essentials-disableFunctions.png | center]]
  
 
To achieve this, simply call <javadoc directory='zss' method="disableUserAction(org.zkoss.zss.ui.AuxAction, boolean)">org.zkoss.zss.ui.Spreadsheet</javadoc>
 
To achieve this, simply call <javadoc directory='zss' method="disableUserAction(org.zkoss.zss.ui.AuxAction, boolean)">org.zkoss.zss.ui.Spreadsheet</javadoc>
<source lang='java' high='22'>
+
<source lang='java' highlight='22'>
 
package org.zkoss.zss.essential.advanced.customization;
 
package org.zkoss.zss.essential.advanced.customization;
  
Line 18: Line 23:
 
  */
 
  */
 
@SuppressWarnings("serial")
 
@SuppressWarnings("serial")
public class DisableActionsComposer extends SelectorComposer<Component> {
+
public class DisableFunctionsComposer extends SelectorComposer<Component> {
  
 
@Wire
 
@Wire
Line 32: Line 37:
  
 
Except sheet operations, you can also disable functions on the toolbar and the context menu. Take a look at <javadoc directory='zss'>org.zkoss.zss.ui.AuxAction</javadoc> for a complete list of functions you can disable.
 
Except sheet operations, you can also disable functions on the toolbar and the context menu. Take a look at <javadoc directory='zss'>org.zkoss.zss.ui.AuxAction</javadoc> for a complete list of functions you can disable.
 +
 +
 +
 +
 +
{{ZKSpreadsheetEssentialsPageFooter}}

Latest revision as of 12:50, 19 January 2022




Spreadsheet provides API to disable its functions. The API can be very useful when you implement your user permission features. In the example application below, since we disable all sheet related functions except one, you can see the corresponding menu items are disabled (in grey color).

Zss-essentials-disableFunctions.png

To achieve this, simply call Spreadsheet.disableUserAction(AuxAction, boolean)

package org.zkoss.zss.essential.advanced.customization;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.CheckEvent;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.*;
import org.zkoss.zss.ui.*;

/**
 * This class demonstrates how to disable functions.
 * @author Hawk
 *
 */
@SuppressWarnings("serial")
public class DisableFunctionsComposer extends SelectorComposer<Component> {

	@Wire
	private Spreadsheet ss;
	
	@Listen("onCheck = #add")
	public void disableAdd(CheckEvent event) {
		ss.disableUserAction(AuxAction.ADD_SHEET, !event.isChecked());
	}
...
}

Except sheet operations, you can also disable functions on the toolbar and the context menu. Take a look at AuxAction for a complete list of functions you can disable.



All source code listed in this book is at Github.


Last Update : 2022/01/19

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