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

推荐订阅源

AI
AI
博客园 - 叶小钗
Blog — PlanetScale
Blog — PlanetScale
Microsoft Azure Blog
Microsoft Azure Blog
Vercel News
Vercel News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
阮一峰的网络日志
阮一峰的网络日志
D
Docker
Jina AI
Jina AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The Register - Security
The Register - Security
J
Java Code Geeks
S
SegmentFault 最新的问题
月光博客
月光博客
G
Google Developers Blog
美团技术团队
Last Week in AI
Last Week in AI
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
T
The Blog of Author Tim Ferriss
腾讯CDC
Recent Announcements
Recent Announcements
Recorded Future
Recorded Future
The Cloudflare Blog
有赞技术团队
有赞技术团队
博客园_首页
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
B
Blog
I
InfoQ
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
F
Fortinet All Blogs
B
Blog RSS Feed
Engineering at Meta
Engineering at Meta
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
MongoDB | Blog
MongoDB | Blog
爱范儿
爱范儿
D
DataBreaches.Net
F
Full Disclosure
M
MIT News - Artificial intelligence
博客园 - 司徒正美
H
Help Net Security

博客园 - 心利

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"]);