SharePoint自定义功能区操作中的{ItemId}为空

时间:2011-10-10 00:54:50

标签: sharepoint-2010

正如标题所示,{ItemId}对于下面列出的代码为空。我在博客上看到,自定义功能区操作中可能没有实现令牌。谁能证实这一点?

请查看下面的Elements.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction ScriptSrc="ADBTicketing/scripts/CustomActions.js" Location="ScriptLink" RegistrationType="List" RegistrationId="12000"></CustomAction>
      <CustomAction Id="Ribbon.ListItem.Manage.AddAButton.ADBServices.EmailStatus"
                    Location="CommandUI.Ribbon" RegistrationType="List" RegistrationId="12000">
<CommandUIExtension>
  <CommandUIDefinitions>
    <CommandUIDefinition Location="Ribbon.ListItem.Manage.Controls._children">
      <Button Id="Ribbon.ListItem.Manage.ADBServices.EmailStatus"
              Command="EmailStatusOfItem"
              Image32by32="/_layouts/Images/ADBTicketing/EmailClient.png"
              LabelText="E-mail Status"
              Sequence="21"
              TemplateAlias="o1"/>
    </CommandUIDefinition>
  </CommandUIDefinitions>
  <CommandUIHandlers>
    <CommandUIHandler Command="EmailStatusOfItem"
                      CommandAction="javascript:addCommentToTicket({ItemId});"></CommandUIHandler>
  </CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>

谢谢, 约书亚

2 个答案:

答案 0 :(得分:3)

在视图功能区中使用

SelectedItemId

而不是

ItemId

答案 1 :(得分:0)

您可以在CommandAction中使用它,但不能在EnabledScript中使用它,因为我发现...

因此,对于您的工作,您将传递给javascript并使用单引号括起来: 的commandAction = “JavaScript的:addCommentToTicket( '{}项目Id');”