隐藏sharepoint列表字段栏位
这里笔者介绍三种大家常用的方法(针对刚接触这块的朋友)。
第一种:用JS 脚本隐藏,不够这种方法有个缺点就是,你所隐藏的字段在你第一次加载页面的时候,页面会快速的刷下窗体,之前被隐藏的字段会在第一时间在你眼皮底下呈现,也快速的在你眼皮底下OVER。给客户带来极大的不爽。
第三种呢就是针对定制教复杂的列表定制,这时我们解决的办法一般是自己定制列表模板然后替换之前的,具体的操作方法可以借助第三方定制工具如jianyi的SPCamleditor(列表编辑器)具体可查看http://www.cnblogs.com/jianyi0115/archive/2008/05/04/1182483.html
第一种:用JS 脚本隐藏,不够这种方法有个缺点就是,你所隐藏的字段在你第一次加载页面的时候,页面会快速的刷下窗体,之前被隐藏的字段会在第一时间在你眼皮底下呈现,也快速的在你眼皮底下OVER。给客户带来极大的不爽。
1<script type="text/javascript" language="javascript">
2 <!--搜索对应到每个字段的文本输入框-->
3function searchFieldEditorElement(tagName, identifier, title) {
4 var len = identifier.length;
5 var tags = document.getElementsByTagName(tagName);
6 for (var i=0; i < tags.length; i++) {
7 var tempString = tags[i].id;
8 if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len)) {
9 return tags[i];
10 }
11 }
12 return null;
13}
14
15// 搜索对应到每个字段的“<TR>”标签
16function searchParentTR(element)
17{
18 var parentElement = element.parentElement;
19 if (parentElement == null)
20 {
21 return element;
22 }
23 if (parentElement.tagName.toLowerCase() == "tr")
24 {
25 return parentElement;
26 }
27 return searchParentTR(parentElement);
28}
29function setFieldControls()
30{
31 var txtTitle1 = searchFieldEditorElement("select", "DropDownChoice", "审批结果");
32 if (txtTitle1 != null)
33 {
34 var parentTr = searchParentTR(txtTitle1);
35 parentTr.style.display = "none";
36 //txtTitle1.readOnly=true;
37 }
38 // 将“标题”字段所对应的行隐藏起来
39 var txtTitle=searchFieldEditorElement("span", "", "全天事件");
40 if (txtTitle != null)
41 {
42 var parentTr = searchParentTR(txtTitle);
43 parentTr.style.display = "none";
44 }
45 txtTitle=searchFieldEditorElement("span", "", "重复");
46 if (txtTitle != null)
47 {
48 var parentTr = searchParentTR(txtTitle);
49 parentTr.style.display = "none";
50 }
51 txtTitle=searchFieldEditorElement("span", "", "工作区");
52 if (txtTitle != null)
53 {
54 var parentTr = searchParentTR(txtTitle);
55 parentTr.style.display = "none";
56 }
57
58 txtTitle=searchFieldEditorElement("input", "", "说明1");
59 if (txtTitle != null)
60 {
61 var parentTr = searchParentTR(txtTitle);
62 parentTr.style.display = "none";
63 }
64 }
65
66// 指定在页面载入后运行指定的JS函数
67_spBodyOnLoadFunctionNames.push("setFieldControls");
68
69</script>
70
第2种呢,就很简单。。不够实现这种方法一般是客户对列表的定制要求不是很高,那这时候我们通常用数据视图展示列表。用SPD新建数据视图,加载你要显示的列表。然后找到你想隐藏的字段,这是找到他的相应单元格标签<td></td>,然后设置style="display:none";搞定。2 <!--搜索对应到每个字段的文本输入框-->
3function searchFieldEditorElement(tagName, identifier, title) {
4 var len = identifier.length;
5 var tags = document.getElementsByTagName(tagName);
6 for (var i=0; i < tags.length; i++) {
7 var tempString = tags[i].id;
8 if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len)) {
9 return tags[i];
10 }
11 }
12 return null;
13}
14
15// 搜索对应到每个字段的“<TR>”标签
16function searchParentTR(element)
17{
18 var parentElement = element.parentElement;
19 if (parentElement == null)
20 {
21 return element;
22 }
23 if (parentElement.tagName.toLowerCase() == "tr")
24 {
25 return parentElement;
26 }
27 return searchParentTR(parentElement);
28}
29function setFieldControls()
30{
31 var txtTitle1 = searchFieldEditorElement("select", "DropDownChoice", "审批结果");
32 if (txtTitle1 != null)
33 {
34 var parentTr = searchParentTR(txtTitle1);
35 parentTr.style.display = "none";
36 //txtTitle1.readOnly=true;
37 }
38 // 将“标题”字段所对应的行隐藏起来
39 var txtTitle=searchFieldEditorElement("span", "", "全天事件");
40 if (txtTitle != null)
41 {
42 var parentTr = searchParentTR(txtTitle);
43 parentTr.style.display = "none";
44 }
45 txtTitle=searchFieldEditorElement("span", "", "重复");
46 if (txtTitle != null)
47 {
48 var parentTr = searchParentTR(txtTitle);
49 parentTr.style.display = "none";
50 }
51 txtTitle=searchFieldEditorElement("span", "", "工作区");
52 if (txtTitle != null)
53 {
54 var parentTr = searchParentTR(txtTitle);
55 parentTr.style.display = "none";
56 }
57
58 txtTitle=searchFieldEditorElement("input", "", "说明1");
59 if (txtTitle != null)
60 {
61 var parentTr = searchParentTR(txtTitle);
62 parentTr.style.display = "none";
63 }
64 }
65
66// 指定在页面载入后运行指定的JS函数
67_spBodyOnLoadFunctionNames.push("setFieldControls");
68
69</script>
70
第三种呢就是针对定制教复杂的列表定制,这时我们解决的办法一般是自己定制列表模板然后替换之前的,具体的操作方法可以借助第三方定制工具如jianyi的SPCamleditor(列表编辑器)具体可查看http://www.cnblogs.com/jianyi0115/archive/2008/05/04/1182483.html