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

推荐订阅源

博客园 - 三生石上(FineUI控件)
Hugging Face - Blog
Hugging Face - Blog
M
MIT News - Artificial intelligence
T
Tailwind CSS Blog
Webroot Blog
Webroot Blog
S
Secure Thoughts
N
News and Events Feed by Topic
月光博客
月光博客
TaoSecurity Blog
TaoSecurity Blog
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
N
News | PayPal Newsroom
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
小众软件
小众软件
Recent Commits to openclaw:main
Recent Commits to openclaw:main
P
Privacy & Cybersecurity Law Blog
GbyAI
GbyAI
K
Kaspersky official blog
WordPress大学
WordPress大学
P
Proofpoint News Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 叶小钗
W
WeLiveSecurity
Jina AI
Jina AI
The Cloudflare Blog
Project Zero
Project Zero
Simon Willison's Weblog
Simon Willison's Weblog
V
Vulnerabilities – Threatpost
L
LangChain Blog
Forbes - Security
Forbes - Security
PCI Perspectives
PCI Perspectives
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
Recorded Future
Recorded Future
博客园 - 【当耐特】
H
Heimdal Security Blog
A
About on SuperTechFans
Cisco Talos Blog
Cisco Talos Blog
T
Threat Research - Cisco Blogs
云风的 BLOG
云风的 BLOG
Spread Privacy
Spread Privacy
L
LINUX DO - 最新话题
L
Lohrmann on Cybersecurity
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
I
Intezer
Martin Fowler
Martin Fowler
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint

博客园 - 心利

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