How to enable the button which is created using custom control

泪湿孤枕 提交于 2020-01-07 09:38:14

问题


I need to create buttons one below the other in tridion ribbon.

I have created an usercontrol and it was appearing on the ribbon but in disabled mode. In the "http://tridiondeveloper.com/ribbon-item-group"; it was mentioned to include <ext:issmallbutton>true</ext:issmallbutton> inside my extension element in the configuration. I have included it in the extension.config file. But i am facing error like "Loading extension failed - has invalid child element 'issmallbutton'. So, currently i ignored this step and the buttons were in disabled mode.

Could you please let me understand where i need to add this.(<ext:issmallbutton>true</ext:issmallbutton> ) and to make the buttons enable.


回答1:


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.




回答2:


To enable a button you need its isEnabled method to return true. issmallbutton only determines the size of the button in the toolbar. For information on how to create a button extension please look at the many other questions on this same subject...



来源:https://stackoverflow.com/questions/11897324/how-to-enable-the-button-which-is-created-using-custom-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!