在功能区中添加的按钮在sharepoint中被禁用

时间:2013-11-25 12:28:46

标签: .net ribbon

我尝试在sharepoint中添加按钮到功能区。但是通过从列表中选择项目不会激活该按钮。

我的项目是作为SandBoxSolution的Sharepoint2010项目

这是代码:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="Ribbon.ListItem.Custom" 
                Location="CommandUI.Ribbon" 
                RegistrationId="100" 
                RegistrationType="List" 
                Title="CorrectiveActions">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.ListItem.Groups._children">
          <Group
            Id="Ribbon.ListItem.Custom"
            Sequence="55"
            Description="Custom Group"
            Title="Custom"
            Command="EnableCustomGroup"
            Template="Ribbon.Templates.Flexible2">
              <Controls Id="Ribbon.ListItem.Custom.Controls">
                <Button Id="Ribbon.ListItem.Custom.Approve" 
                        Command="Ribbon.ApproveItems" 
                        Image16by16="../_layouts/images/configureWebPartHH.png"
                        Image32by32="../_layouts/images/configureWebPartHS.png"
                        TemplateAlias="o1"
                        LabelText="Approve" 
                        ToolTipTitle="Approve Displayer" 
                        ToolTipDescription="Approve items." 
                        Sequence="5"
                        />
              </Controls>
          </Group>
        </CommandUIDefinition>
        <CommandUIDefinition
          Location="Ribbon.ListItem.Scaling._children">
          <MaxSize
            Id="Ribbon.ListItem.Scaling.Custom.MaxSize"
            Sequence="15"
            GroupId="Ribbon.ListItem.Custom"
            Size="LargeLarge" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler 
          EnabledScript="javascript: function CheckBoton() { var items = GetSelectedPrincipals(); return (items.strIds.length > 0); } CheckBoton();"
          Command="Ribbon.ApproveItems" 
          CommandAction="javascript:  SP.UI.Notify.addNotification('Hello from the notification area'); " />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction> 
</Elements>

EnabledScript是:

EnabledScript="javascript: function CheckBoton() { var items = GetSelectedPrincipals(); return (items.strIds.length > 0); } CheckBoton();"

有人可以帮助我吗?

0 个答案:

没有答案