如何启用使用自定义控件创建的按钮 [英] How to enable the button which is created using custom control

查看:26
本文介绍了如何启用使用自定义控件创建的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 tridion 功能区中创建一个在另一个下方的按钮.

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

我创建了一个用户控件,它出现在功能区上,但处于禁用模式.在http://tridiondeveloper.com/ribbon-item-group"中;提到在我的配置中的扩展元素中包含 true .我已将其包含在 extension.config 文件中.但是我遇到了加载扩展失败 - 具有无效的子元素‘issmallbutton’的错误.因此,目前我忽略了这一步,按钮处于禁用模式.

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.

您能否让我了解我需要在何处添加此内容.(true</ext:issmallbutton>)并使按钮启用.

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

推荐答案

如 Jeremy 的回答所示,您不需要 ext:issmallbutton 来启用您的按钮(您提到 我关于 Tridion Developer 的文章,其中我特别声明 ext:issmallbutton 不是当您想将按钮堆叠在彼此之上时使用).

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

您可能应该尝试调试 JavaScript 并查看 _isAvailable(selection, pipeline)_isEnabled(selection, pipeline) 方法中发生的情况.

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

isAvailable 方法应指示该命令是否适用于所选项目,而 isEnabled 方法应指示该命令是否可以执行.我通常只是让 isEnabled 方法返回 isAvailable 的结果(因为当按钮可用时,它应该大部分时间也被启用).选择页面后如何启用按钮的示例如下所示:

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);
}; 

现在 ext:issmallbutton 元素与这一切都无关,但是如果你想知道应该在哪里使用它,它应该放在 ext 中:扩展元素如下:

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>

您可以在 在 8 中设置 SDL Tridion 2011 GUI 扩展中找到更多信息步骤.

这篇关于如何启用使用自定义控件创建的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆