[Solved] How to enable the button which is created using custom control


As indicated by Jeremy’s answer, you don’t need the ext:issmallbutton to enable your button (you mention my article on Tridion Developer, where I specifically state that the ext:issmallbutton is not to be used when you want to stack buttons on top of eachother).

You probably should try to debug your JavaScript and see what is happening in your _isAvailable(selection, pipeline) and _isEnabled(selection, pipeline) methods.

The isAvailable method should indicate whether the command is applicable for the selected item(s) and the isEnabled method indicates whether the command can be executed. I usually just let the isEnabled method return the result of the isAvailable one (since when the button is available, it should most of the time also be enabled). An example of how to enable a button when you have selected a Page would look something like this:

Example.PageBtn.prototype._isAvailable = function PageBtn$_isAvailable(selection, pipeline) {
    if (pipeline) {
        pipeline.stop = false;
    }

    if (selection.getCount() == 1) {
        var itemType = $models.getItemType(selection.getItem(0));
        return itemType && (itemType == $const.ItemType.PAGE);
    }
    return false;
};
Example.PageBtn.prototype._isEnabled = function PageBtn$_isEnabled(selection, pipeline) {
    if (pipeline) {
        pipeline.stop = false;
    }
    return this._isAvailable(selection);
}; 

Now the ext:issmallbutton element has nothing to do with this all, but if you would like to know where that should be used exactly, it is supposed to go inside the ext:extensionelement like so:

<ext:extension assignid="PageBtn" groupid="MyGroup" name="Example" pageid="HomePage">
    <ext:command>PageBtn</ext:command>
    <ext:title>Example</ext:title>
    <ext:issmallbutton>true</ext:issmallbutton>
    <ext:dependencies>
        <cfg:dependency>Example.Commands</cfg:dependency>
    </ext:dependencies>
    <ext:apply>
        <ext:view name="DashboardView">
            <ext:control id="DashboardToolbar" />
        </ext:view>
    </ext:apply>
</ext:extension>

You can find more information in Setting up a SDL Tridion 2011 GUI extension in 8 steps.

3

solved How to enable the button which is created using custom control