向 ListViewWebpart 的每一行添加一个复选框
我正在开发一个 WSS 3 站点,该站点有一个显示各种列的 ListViewWebpart。
我需要向每一行添加一个复选框,并向标题添加一个按钮,该按钮将为所选行执行服务器端操作。
我是否需要制作自己的自定义 Web 部件,或者 ListViewWebpart 是否支持复选框?
向每一行添加复选框
我发现了一篇文章 ListViewWebpart 中的复选框 这表明
...添加复选框,选择多个 listitem,在自定义列表中,声明 如下所示的 xml 字符串。
<Field Type="Computed" ReadOnly="TRUE" Name="ListItemSelection" DisplayName="Select" Sortable="FALSE" Filterable="FALSE" EnableLookup="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="ListItemSelection">
<FieldRefs>
<FieldRef Name="ID" />
</FieldRefs>
<DisplayPattern>
<HTML><![CDATA[<input type="checkbox" ]]></HTML>
<HTML><![CDATA[LItemId="]]></HTML>
<Column Name="ID" HTMLEncode="TRUE" />
<HTML><![CDATA["/> ]]></HTML>
</DisplayPattern>
</Field>
并致电 list.Fields。AddFieldAsXml (“xml 细绳”);。将此作为第一个 自定义列表视图中的列。
我假设后一部分需要 SPList。例如,
SPList list = SPContext.Current.Web.Lists["MyList"];
list.Fields.AddFieldAsXml(stringWithXmlFieldDefinition);
向标题行添加按钮
标题按钮的一个选项是 自定义操作。这应该在工具栏中创建一个按钮。
I'm working on a WSS 3 site that has a ListViewWebpart displaying various columns.
I need to add a checkbox to each row and a button to the header that will perform a server side action for the selected rows.
Do I need to make my own custom webpart or can the ListViewWebpart support checkboxes?
Adding checkboxes to each row
I've found a post Checkbox in ListViewWebpart which suggests
...to add a checkbox, to select multiple
listitem, in the custom list, declare
a xml string as follows.
<Field Type="Computed" ReadOnly="TRUE" Name="ListItemSelection" DisplayName="Select" Sortable="FALSE" Filterable="FALSE" EnableLookup="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="ListItemSelection">
<FieldRefs>
<FieldRef Name="ID" />
</FieldRefs>
<DisplayPattern>
<HTML><![CDATA[<input type="checkbox" ]]></HTML>
<HTML><![CDATA[LItemId="]]></HTML>
<Column Name="ID" HTMLEncode="TRUE" />
<HTML><![CDATA["/> ]]></HTML>
</DisplayPattern>
</Field>
and call the
list.Fields.AddFieldAsXml(“xml
string”);. Include this as a first
column in your custom list’s view.
I'm assuming the latter part requires a SPList. E.g.
SPList list = SPContext.Current.Web.Lists["MyList"];
list.Fields.AddFieldAsXml(stringWithXmlFieldDefinition);
Adding a button to the header row
One option for the header button is a CustomAction. This should create a button in the toolbar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个帖子,用于创建自定义 Web 部件,然后您可以使用您找到的帖子向自定义 Web 部件添加复选框(ListViewWebpart 中的复选框)。
请注意,
list.Fields.AddFieldAsXml(stringWithXmlFieldDefinition);
最终可能会向您的共享点添加许多重复的复选框。重复项可以从数据库中删除,并位于 AllLists 表的 tp_Fields 列中。要找到正确的字段,您可以通过列表 GUI 进行搜索。
然后,更新字段
您可以简单地添加一个按钮
,但可能您需要创建另一个工具栏来保存该按钮,您甚至可以创建自己的工具栏。您只需将其放入
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES\YourCutomToolBar.ascx
Here is a post to create a custom web part, then you can add a check box to your custom web part using the post you have found (Checkbox in ListViewWebpart).
Be aware that,
list.Fields.AddFieldAsXml(stringWithXmlFieldDefinition);
can end up adding many duplicated check boxes to you sharepoint. The duplicated can be deleted from database and are located at AllLists table, tp_Fields column.To find the right fields, you can search by the list guid.
then, update the fields
You can simply add a button by
but possibly you need create another toolbar to hold the button, you can even create your own toolbar. You just need to put it in
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES\YourCutomToolBar.ascx