Disable Functions"

From Documentation
(Created page with "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...")
 
Line 1: Line 1:
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 functions including "Add a Sheet", "Delete a Sheet", and "Copy a Sheet", 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'>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' high='22'>
 
package org.zkoss.zss.essential.advanced.customization;
 
package org.zkoss.zss.essential.advanced.customization;

Revision as of 04:13, 12 May 2015

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 DisableActionsComposer 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.