I have created a GUI button, and i would like to enable the button when the user selects any folder only.
I have tried to give the config xml like below, but its displaying always.
<ext:apply>
<ext:view name="DashboardView">
<ext:control id="DashboardToolbar"/>
</ext:view>
<ext:view name="FolderView">
<ext:control id="ItemToolbar"/>
</ext:view>
</ext:apply>
You have to implement the isEnabled
method in the Command
interface with the following check, to make sure that the type of the selected element is FOLDER.
YourEditor.YourCommand.prototype.isEnabled =
function YourCommand$isEnabled(selection) {
var itemID = selection.getItem(0);
if ($models.getItemType(itemID) != $const.ItemType.FOLDER) {
return false;
}
else
return true;
};
true
on the isEnabled
function, the button will be enabled.false
, the button will be disabledIf you need further information on how to setup the extension you can refer to: