惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 心利

DocOptimizer 0.9.0 Beta Released Drag & Drop between SharePoint Document libraries Improving SharePoint User Experience With JQuery-Client Side Form Validate SharePoint How To:定位错误:“An SPRequest object was not disposed .." SharePoint Tips and Tricks --如何用JS向PeopleEditor填充数据 SharePoint Tips and Tricks -- Ribbon,People Editor 使用T4为数据库自动生成实体类(C#) (Tips&Tricks)用客户端模板精简JavaScript代码 (Tips &Tricks)如何为Windows Mobile 创建拨号连接--C# System.Xml FAQ Part 1 Windows Ce vs Windows Mobile Asp.net程序中生成Excel报表 My Page StartKit项目概览 做一个更好的程序员 .Net类库中实现的HashTable 为Asp.net控件写单元测试(ViewState) - 心利 使用Control Adapters优化Asp.net控件 ViewState 简述一(With Example And Apply to Asp.net) 桌面背景:rss新闻阅读器(图) - 心利
SharePoint GroupedItemPicker Control
心利 · 2013-11-07 · via 博客园 - 心利

这个控件SharePoint用来选择Field ,和Content Type, 以下是一个完整的示例。

           

<SharePoint:GroupedItemPicker ID="SelectColumn" runat="server"

                CandidateControlId="SelectCandidate"

                ResultControlId="SelectResult"

                AddButtonId="AddButton"

                RemoveButtonId="RemoveButton" />

            <table class="ms-long" cellpadding="0" cellspacing="0" border="0">

                <tr>

                    <td class="ms-input">

                        <SharePoint:SPHtmlSelect ID="SelectCandidate" Width="143" Height="125" runat="server" multiple="true" />

                    </td>

                    <td style="padding-left: 10px"/>

                    <td align="center" valign="middle" class="ms-input">

                        <button id="AddButton" runat="server" style="width:80px">

                            <SharePoint:EncodedLiteral ID="EncodedLiteral3" runat="server" Text="<%$Resources:wss,multipages_gip_add%>" EncodeMethod='HtmlEncode' />

                        </button>

                        <br />

                        <br />

                        <button id="RemoveButton" runat="server" style="width:80px">

                            <SharePoint:EncodedLiteral ID="EncodedLiteral4" runat="server" Text="<%$Resources:wss,multipages_gip_remove%>" EncodeMethod='HtmlEncode' />

                        </button>

                    </td>

                    <td style="padding-left: 10px"/>

                    <td class="ms-input">

                        <SharePoint:SPHtmlSelect ID="SelectResult" Width="143" Height="125" runat="server" multiple="true" />

                    </td>

 

                    <td align="center" valign="middle" class="ms-input">

                        <input type="button" runat="server" id="SelectResultUp" value="Up" onclick="listbox_move(SelectResultID, 'up'); GipSetHiddenControlValue(window[SelectColumnsID + '_m']);"/>

                         <br />

                        <br />

                        <input type="button" runat="server" id="SelectResultDown" value="Down" onclick="listbox_move(SelectResultID, 'down'); GipSetHiddenControlValue(window[SelectColumnID + '_m']);"/>

                    </td>

 

                </tr>

            </table>

服务器端代码:

     foreach (SPField field in SPContext.Current.List.Fields)

            {

                SelectColumn.AddChoice(field.InternalName, field.Title, string.Empty, string.Empty);

            }

1 调整选中项的顺序:

function listbox_move(listID, direction) {

    var listbox = document.getElementById(listID);

 

    if (direction == "up") {

        for (var i = 0; i < listbox.options.length; i++) {

            var option = listbox.options[i];

            if (option.selected == true) {

                listbox_moveOption(listbox, i, direction);

            }

        }

    } else {

        for (var i = listbox.options.length-1; i >=0; i--) {

            var option = listbox.options[i];

            if (option.selected == true) {

                listbox_moveOption(listbox, i, direction);

            }

        }

    }

}

 

function listbox_moveOption(listbox, i, direction) {

    var selIndex = i;

 

    if (-1 == selIndex) {

        alert("Please select an option to move.");

        return;

    }

 

    var increment = -1;

    if (direction == 'up')

        increment = -1;

    else

        increment = 1;

 

    if ((selIndex + increment) < 0 ||

        (selIndex + increment) > (listbox.options.length - 1)) {

        return;

    }

    var selValue = listbox.options[selIndex].value;

    var selText = listbox.options[selIndex].text;

    listbox.options[selIndex].value = listbox.options[selIndex + increment].value

    listbox.options[selIndex].text = listbox.options[selIndex + increment].text

    listbox.options[selIndex].selected = false;

    listbox.options[selIndex + increment].value = selValue;

    listbox.options[selIndex + increment].text = selText;

    listbox.options[selIndex + increment].selected = true;

}

2, 更新HiddenField

 函数 GipSetHiddenControlValue 位于 "%program files%\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\GroupedItemPicker.js"

var groupItemData = [];

        for (var i = 0, max = fields.length; i < max; i++) {

            options += "<option value=\"" + fields[i].Second + "\">" + STSHtmlEncode(fields[i].First) + "</option>";

            groupItemData[i+1] = [fields[i].Second, fields[i].First];

        }

 

        spbLookup(this.lookupFieldSelect).html(options);

        window[this.context.appearanceColumnsID + "_m"].data = [groupItemData];

        spbLookup(this.appearanceColumnsSelectResult).html("");

        GipRefreshGroupCore(window[this.context.appearanceColumnsID + "_m"]);