如何根据表单状态隐藏香草按钮 [英] How to hide a vanilla button according to form state

查看:176
本文介绍了如何根据表单状态隐藏香草按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据表单状态隐藏我的保存 香草按钮。当表单状态!=创建时,香草按钮不应显示。我尝试了不同的方法,但无济于事:

I am trying to hide my SAVE vanilla button according to form state. when the form state != create the vanilla button should not display. I tried different things but nothing works:


  1. 我在js中创建了一个函数,如果表单处于创建状态,则该函数返回true

  1. I create a function in js that returns true if form is create state

function isHideState(){
formstate = Xrm.Page.ui.getFormType();
if(formstate == formType.create){
return true;}
else{
return false;}
}


  • 我添加了显示规则并将其连接到与js函数相关的命令:
    我的规则是:FormStateRule和状态:创建

  • I added a disply rule and connected it to my command that relevant to the js function : my rule is : FormStateRule and state: Create

    我错过了什么吗?

    更新:更具体-我需要仅在创建模式下才能看到该按钮。

    UPDATE: to be more specific - I need the button to be seen only on create mode.

    推荐答案

    注意:每当您自定义香草按钮(您的情况下为OOB保存按钮)时,请务必先右键单击功能区工作台中的按钮点击自定义按钮/命令以保留 OOB行为和

    Note: Whenever you are customizing the vanilla button (OOB Save button in your case), Make sure to start by right click the button in Ribbon workbench & click customize button/command to "retain" the OOB behavior & add your customizations on top of it.

    更改此行

    if(formstate = formType.create){
    

    进入

    if(formstate == formType.create){
    

    Single =用于分配;

    Single = is for assignment; double = is for comparison.

    更新

    RibbonDiffXml遵循/期望命令

    RibbonDiffXml follows/expects this structure in command:

    <CommandDefinition
    Id="String">
     <EnableRules />
     <DisplayRules />
     <Actions />
    </CommandDefinition>
    

    按钮;

    <Button Alt="String"
      Command="String"
      CommandType=["General" | "OptionSelection" | "IgnoredByMenu" ]
      CommandValueId="String"
      Description="String"
      Id="String"
      Image16by16="String"
      Image16by16Class="String"
      Image16by16Left="Non Positive Integer"
      Image16by16Top="Non Positive Integer"
      Image32by32="String"
      Image32by32Class="String"
      Image32by32Left="String"
      Image32by32Top="String"
      LabelCss="String"
      LabelText="String"
      MenuItemId="String"
      ModernCommandType=[ "ControlCommand"| "System"]
      ModernImage="String"
      Sequence="1"
      TemplateAlias="String"
      ToolTipDescription="String"
      ToolTipHelpKeyWord="String"
      ToolTipImage32by32="String"
      ToolTipImage32by32Class="String"
      ToolTipImage32by32Left="Non Positive Integer"
      ToolTipImage32by32Top="Non Positive Integer"
      ToolTipShortcutKey="String"
      ToolTipTitle="String"
    />
    

    2013年之后,命令栏的引入改变了启用规则的行为,类似于显示规则。使用启用规则禁用的按钮将隐藏该按钮以利用命令栏中其他按钮的空间(因为总是存在一些限制,例如命令栏中的7或9个按钮与功能区不同)。

    After 2013, commandbar introduction changed the behavior of Enable rule similar to Display rule. Disabled buttons using Enable rule will hide the button to utilize the space for other buttons in command bar (as there are always limitation like 7 or 9 buttons in command bar unlike Ribbon).

    启用按钮再次切换后将像显示/隐藏一样(类似于显示规则)。也许您可以按照以下博客文章来实现自己的目标。

    Enabling buttons again will act like show/hide once switched (similar to Display rule). Probably you can follow this blogpost to achieve yours.


    要记住的重要一件事是添加命令的启用规则。通常会错过这一点,有人创建了启用规则,但却忘记了将其添加到按钮命令中。

    An important thing to remember is to add the enable rule(s) to the command. This is commonly missed, someone creates an enable rule but forgets to add it to the button command.

    如果您忘记将启用规则添加到命令中,则按钮将显示在所有状态/表格的各个阶段。如果您忘记将命令添加到按钮,则该按钮将不会显示在表单上。

    If you forget to add enable rules to the command then the button will show on all states/stages of the form. If you forget to add the command to the button, then the button will not show up on the form.

    这篇关于如何根据表单状态隐藏香草按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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