SharePoint Tips and Tricks -- Ribbon,People Editor

Ribbon

   

How To在非"Application Page"页面上添加Ribbon Tool Bar?

   

需要在Head部分添加Ribbon控件

   

<head id="Head1" runat="server">

<SharePoint:SPRibbon ID="SPRibbon2" runat="server" PlaceholderElementId="RibbonContainer" CssFile="">

<SharePoint:SPRibbonPeripheralContent runat="server" Location="TabRowRight" ID="SPRibbonPeripheralContent1" CssClass="s4-trc-container s4-notdlg" ></SharePoint:SPRibbonPeripheralContent>

</SharePoint:SPRibbon>

   

How To 在"Application Page"上添加Contextual Tab?

   

1 ContextualGroup添加Command属性

 

<ContextualGroup Color="Magenta" Command="CustomContextualTab.EnableContextualGroup" Id="Ribbon.CustomContextualTabGroup"

Title="Custom Contextual Tab Group"

Sequence="502"

ContextualGroupId="CustomContextualTabGroup">

   

2 在您自定义的PageComponent中处理ContextualGroup相关的Command.

例如上文中的ContextualGroup,您需要在getGlobalCommands方法返回的命令数组中,包含"CustomContextualTab.EnableContextualGroup",并在canHandleCommand返回True.

   

People Editor

   

How To JavaScriptPeopleEditor控件赋值?

   

function setPeoplePicker(pickerid, value) {

var field = $("#" + pickerid);

if (field.find('.ms-inputuserfield:visible').length > 0) {

// IE

var userlist = field.find('.ms-inputuserfield').html();

field.find('.ms-inputuserfield').html(userlist+";"+value);

field.find('img:first').click();

} else {

// FF

var userlist = field.find("textarea:first").val();

field.find("textarea:first").val(userlist + ";" + value);

}

}

$(document).ready(function () {

setPeoplePicker("<%=MyPeopleEditor.ClientID%>", "CustomValue");

posted @ 2011-09-22 16:31  心利  阅读(410)  评论(0编辑  收藏  举报
SharePoint Add-ons