Disable Functions

From Documentation
Revision as of 04:07, 12 May 2015 by Hawk (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

Zss-essentials-disableFunctions.png

To achieve this, simply call Spreadsheet

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.