CRM 2011 - 在SUBGRID功能区中使用SelectionCountRule时出现问题/错误?

时间:2011-09-06 19:40:14

标签: xml sharepoint ribbon crm dynamics-crm-2011

当我在子网格中使用“自定义按钮”时,我在使用 SelectionCountRule 时遇到问题。我希望仅在选择一个或多个项目时启用该按钮。但它不能正常工作。当我选择“GRID”的1项时,按钮不会启用。我首先必须单击“子网格”或“表单”上的某个位置才能选择按钮。当我取消选择一行时,有时会发生同样的情况。他们可以点击“按钮”,但它应该被禁用。

这是一个可以通过一些JQuery或解决方法解决的Bug吗?对前任来说真的很烦人。在按钮启用之前选择2个项目,并且在没有选择行的情况下他们可以点击按钮真的很烦人。如果我点击表单或网格上的其他位置,按钮就会完成它应该做的......

我的功能区部件无效:

<EnableRule Id="HoldAll.EnableRule">
  <SelectionCountRule AppliesTo="SelectedEntity" Minimum="1"></SelectionCountRule>
</EnableRule>

<EnableRule Id="HoldAllSub.EnableRule">
  <SelectionCountRule AppliesTo="SelectedEntity" InvertResult="1" Maximum="0"></SelectionCountRule>
</EnableRule>

正如你所看到的,我认为我做错了什么......有没有办法解决这个问题?

亲切的问候, 弗雷德里克

1 个答案:

答案 0 :(得分:1)

简答:正确定义了所提供代码中的第一个启用规则。可能遇到的问题取决于如何使用启用规则。

答案很长:我在分割按钮的子网格中遇到了一个所描述的问题 - 带有按钮项下拉列表的功能区按钮。当“1或更多”启用规则应用于下拉列表中的某个项目 - 但不应用于功能区按钮本身时,启用不会从下拉项目向上级联到功能区按钮。必须将启用规则应用于所有项目。

以下是一个完整的例子:

<RibbonDiffXml>
  <CustomActions>
    <!-- SubGrid - Service Requests Group - Scaling Definition -->
    <CustomAction Id="orgname.entityname.subgrid.ServiceRequest.Popup.CustomAction"
                  Location="Mscrm.SubGrid.entityname.MainTab.Scaling._children"
                  Sequence="140">
      <CommandUIDefinition>
        <Scale Id="orgname.entityname.subgrid.ServiceRequest.Popup.1"
                GroupId="orgname.entityname.subgrid.ServiceRequest.Group"
                Sequence="85"
                Size="Popup" />
      </CommandUIDefinition>
    </CustomAction>
    <!-- SubGrid - Service Requests Group - Max Size Definition -->
    <CustomAction Id="orgname.entityname.subgrid.ServiceRequest.MaxSize.CustomAction"
                  Location="Mscrm.SubGrid.entityname.MainTab.Scaling._children"
                  Sequence="120">
      <CommandUIDefinition>
        <MaxSize Id="orgname.entityname.subgrid.ServiceRequest.MaxSize"
                  GroupId="orgname.entityname.subgrid.ServiceRequest.Group"
                  Sequence="21"
                  Size="LargeLarge" />
      </CommandUIDefinition>
    </CustomAction>
    <!-- SubGrid - Service Requests Group - Group and Split-Button Definition -->
    <CustomAction Id="orgname.entityname.subgrid.ServiceRequest.CustomAction"
                  Location="Mscrm.SubGrid.entityname.MainTab.Groups._children"
                  Sequence="110">
      <CommandUIDefinition>
        <Group Id="orgname.entityname.subgrid.ServiceRequest.Group"
                Command="orgname.entityname.subgrid.ServiceRequest.Command"
                Title="$LocLabels:orgname.entityname.ServiceRequest.Title"
                Sequence="39" Template="Mscrm.Templates.Flexible2"
                Image32by32Popup="$webresource:new_/imgs/icons/ServiceRequest_32x32.png">
          <Controls Id="orgname.entityname.subgrid.ServiceRequest.Controls">

            <!-- Service Requests SplitButton Definition on SubGrid -->
            <SplitButton Id="orgname.entityname.subgrid.ServiceRequest.AddServiceRequest"
                          ToolTipTitle="$LocLabels:orgname.entityname.ServiceRequest.Splitbutton.AddServiceRequest.Label"
                          ToolTipDescription="$LocLabels:orgname.entityname.ServiceRequest.Splitbutton.AddServiceRequest.Tooltip"
                          Command="orgname.entityname.ServiceRequests.subgrid.Splitbutton.AddServiceRequest"
                          Sequence="5"
                          LabelText="$LocLabels:orgname.entityname.ServiceRequest.Splitbutton.AddServiceRequest.Label"
                          Alt="$LocLabels:orgname.entityname.ServiceRequest.Splitbutton.AddServiceRequest.Label"
                          Image16by16="$webresource:new_/imgs/icons/OrgName_16x16.png"
                          Image32by32="$webresource:new_/imgs/icons/OrgName_32x32.png"
                          TemplateAlias="o1">
              <Menu Id="orgname.entityname.subgrid.ServiceRequest.AddServiceRequest.Menu">
                <MenuSection Id="orgname.entityname.subgrid.ServiceRequest.AddServiceRequest.MenuSection"
                              Sequence="10"
                              DisplayMode="Menu16">
                  <Controls Id="orgname.entityname.subgrid.ServiceRequest.AddServiceRequest.MenuSection.Controls">
                    <!-- SubGrid Split Menu - HoldAll Button definition -->
                    <Button Id="orgname.entityname.subgrid.ServiceRequest.AddServiceRequest.MenuSection.Controls.Button.HoldAll"
                            ToolTipTitle="$LocLabels:orgname.entityname.ServiceRequest.Button.HoldAll.LabelText"
                            ToolTipDescription="$LocLabels:orgname.entityname.ServiceRequest.Button.HoldAll.Description"
                            Command="orgname.entityname.ServiceRequest.subgrid.Splitbutton.HoldAll.Command"
                            Sequence="41"
                            LabelText="$LocLabels:orgname.entityname.ServiceRequest.Button.HoldAll.LabelText"
                            Alt="$LocLabels:orgname.entityname.ServiceRequest.Button.HoldAll.LabelText"
                            Image16by16="$webresource:new_/imgs/icons/HoldAll_16x16.png" />
                  </Controls>
                </MenuSection>
              </Menu>
            </SplitButton>
          </Controls>
        </Group>
      </CommandUIDefinition>
    </CustomAction>
  </CustomActions>
  <Templates>
    <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
  </Templates>
  <CommandDefinitions>

    <!-- SubGrid - Service Requests Group - AddServiceRequest command 
      - this is what happens when the image part of the splitbutton gets clicked -->
    <CommandDefinition Id="orgname.entityname.subgrid.ServiceRequest.Command">
      <EnableRules>
        <EnableRule Id="orgname.entityname.subgrid.SelectionCountAtLeastOne.EnableRule"/>
      </EnableRules>
      <DisplayRules>
        <DisplayRule Id="orgname.entityname.WebClient.DisplayRule" />
      </DisplayRules>
      <Actions />
    </CommandDefinition>

    <!-- SubGrid AddSvcReq command -->
    <CommandDefinition Id="orgname.entityname.ServiceRequests.subgrid.Splitbutton.AddServiceRequest">
      <EnableRules>
        <EnableRule Id="orgname.entityname.subgrid.SelectionCountAtLeastOne.EnableRule" />
      </EnableRules>
      <DisplayRules />
      <Actions />
    </CommandDefinition>

    <!-- SubGrid - Service Requests Group - HoldAll command -->
    <CommandDefinition Id="orgname.entityname.ServiceRequest.subgrid.Splitbutton.HoldAll.Command">
      <EnableRules>
        <EnableRule Id="orgname.entityname.subgrid.SelectionCountAtLeastOne.EnableRule"/>
      </EnableRules>
      <DisplayRules>
        <DisplayRule Id="orgname.entityname.WebClient.DisplayRule"/>
      </DisplayRules>
      <Actions>
        <JavaScriptFunction Library="$webresource:new_/scripts/entityname.js"
                            FunctionName="orgname.entityname.NewServiceRequest">
          <CrmParameter Value="SelectedControlSelectedItemReferences"/>
        </JavaScriptFunction>
      </Actions>
    </CommandDefinition>

  </CommandDefinitions>
  <RuleDefinitions>
    <TabDisplayRules />
    <DisplayRules>
      <DisplayRule Id="orgname.entityname.WebClient.DisplayRule">
        <CrmClientTypeRule Type="Web" />
      </DisplayRule>
    </DisplayRules>
    <EnableRules>
      <EnableRule Id="orgname.entityname.subgrid.OneSelected.EnableRule">
        <SelectionCountRule AppliesTo="SelectedEntity" Maximum="1" Minimum="1" />
      </EnableRule>
      <EnableRule Id="orgname.entityname.subgrid.SelectionCountAtLeastOne.EnableRule">
        <SelectionCountRule AppliesTo="SelectedEntity" Minimum="1" />
      </EnableRule>
      <EnableRule Id="orgname.entityname.WebClient.EnableRule">
        <CrmClientTypeRule Type="Web" />
      </EnableRule>
    </EnableRules>
  </RuleDefinitions>
  <LocLabels>

    <!-- SERVICE REQUESTS GROUP -->

    <!-- ServiceRequest Group Title -->
    <LocLabel Id="orgname.entityname.ServiceRequest.Title">
      <Titles>
        <Title languagecode="1033" description="Service Requests" />
      </Titles>
    </LocLabel>

    <!-- AddServiceRequest Split-Button Label -->
    <LocLabel Id="orgname.entityname.ServiceRequest.Splitbutton.AddServiceRequest.Label">
      <Titles>
        <Title languagecode="1033" description="Add Service Request" />
      </Titles>
    </LocLabel>
    <!-- AddServiceRequest Tooltip -->
    <LocLabel Id="orgname.entityname.ServiceRequest.Splitbutton.AddServiceRequest.Tooltip">
      <Titles>
        <Title languagecode="1033" description="A Service Request tooltip that describes what a Service Request is." />
      </Titles>
    </LocLabel>

    <!-- Hold All Labels -->
    <LocLabel Id="orgname.entityname.ServiceRequest.Button.HoldAll.LabelText">
      <Titles>
        <Title languagecode="1033" description="Hold All" />
      </Titles>
    </LocLabel>
    <LocLabel Id="orgname.entityname.ServiceRequest.Button.HoldAll.Description">
      <Titles>
        <Title languagecode="1033" description="Hold All Description" />
      </Titles>
    </LocLabel>

  </LocLabels>
</RibbonDiffXml>