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 用JavaScript为PeopleEditor控件赋值?
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");