代码之家  ›  专栏  ›  技术社区  ›  Keng

如何更改列表视图中列的宽度是SharePoint?

  •  0
  • Keng  · 技术社区  · 14 年前

    我有SharePoint 2007,我有一个列表视图,它有一个文本字段,当与许多其他字段一起显示时,它只有一个单词那么窄。

    有没有办法在不访问css或其他web编程语言的情况下扩展该列?

    2 回复  |  直到 14 年前
        1
  •  2
  •   Kit Menke    14 年前

    如果不能使用CSS、JavaScript、SharePoint Designer或将任何C代码部署到服务器。。那你就不能改变栏的宽度了。

        2
  •  1
  •   Kelly S. French    14 年前

    尝试使用设置列外观的CSS/JavaScript添加ContentEditor Web部件。你不需要C或设计师。

    我在一个搜索页面上做了类似的事情,我需要一个JavaScript函数来触发,所以我在页面中添加了一个CEWP,代码如下(见下文)。

    您可以更改此项以查找要修改的列的id。请记住,SharePoint中控件的ID是在页面呈现期间生成的,因此您不一定知道确切的ID。这就是为什么此代码查找以'\u PSB\u Show'结尾的ID的锚,而不是查找确切的ID。

    <script type="text/javascript">
    var anchors = document.getElementsByTagName("a");
    var anchor;
    var j; 
    
    // Iterate through all anchors on the page and find the one with ID ending in _PSB_Show
    for (j = 0; j < anchors.length; j++)
    {
       if (anchors[j].id.match(/\_PSB_Show$/) != null)
       {
          anchor = anchors[j];
          break;
       }
    } 
    
    // If the anchor is found and the click is supported in the current browser
    // Perform a click after 100 ms
    if ((anchor != null) && (anchor.click != null))
    {
       setTimeout("anchor.click();", 100);
    }
    </script>