2012-10-22 77 views

回答

3

以下是名为“测试行动1”色带项目(按钮)添加到步骤在SharePoint 2010中使用CustomAction的TemplateType = 10003的列表

1.添加一个新元素并添加以下代码。请注意,有两个CustomActions。一个添加功能区按钮,另一个添加JavaScript文件。

RegistrationId与ListTemplateType相同。

有关默认服务器功能区定制位置的列表,请参阅this article

<?xml version="1.0" encoding="utf-8"?> 
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> 
     <CustomAction ShowInLists="TRUE" Id="TestAction1" RegistrationType="List" RegistrationId="10003" Location="CommandUI.Ribbon"> 
     <CommandUIExtension> 
      <CommandUIDefinitions> 
      <CommandUIDefinition Location="Ribbon.ListItem.Actions.Controls._children"> 
       <Button Id="Ribbon.ListItem.Actions.TestAction1" Alt="Test Action 1" Sequence="10" Image32by32="/_layouts/images/ACTIONSEDITPAGE.PNG" Command="Test_Action1" LabelText="Test Action 1" TemplateAlias="o2"/> 
      </CommandUIDefinition> 
      </CommandUIDefinitions> 
      <CommandUIHandlers> 
      <CommandUIHandler Command="Test_Action1" CommandAction="javascript:TestAction1();" /> 
      </CommandUIHandlers> 
     </CommandUIExtension> 
     </CustomAction> 
     <CustomAction Id="Test.Ribbon.TestScript" Location="ScriptLink" ScriptSrc="~/_layouts/SPTest/TestJScript1.js" /> 
    </Elements> 

2.映射Layouts文件夹并添加TestJScript1.js文件。

function TestAction1() { 
    alert("This the test action 1"); 
} 

查看示例项目结构

Sample Solution Explorer view

相关问题