【问题标题】:I need to concatenate url with sharepoint list tr id我需要将 url 与 sharepoint list tr id 连接起来
【发布时间】:2014-04-20 05:12:57
【问题描述】:

我需要从 ms-unselectedtitle 中提取 ID,它是 SharePoint 2007 列表中 ms-vb-title 的子元素。然后将其与 url 连接以打开一个新窗口。窗口需要使用 window.open() 方法打开,以便我可以控制大小并关闭菜单。通过计算列在列表中创建链接不起作用,因为它只是在包含所有菜单的选项卡中打开一个新窗口。我在这里找到了代码(“@9​​87654321@”),它很接近,但它返回一个 ID 数组,而不是按表行。我是 javascript/jquery 的新手,所以我有点卡住了。请注意,我使用的 ID 嵌入在列表的“标题”字段中。 html部分在这里...

    <TD class=ms-vb-title height="100%" sizset="50" sizcache011076027996994381="6">
       <TABLE onmouseover=OnItem(this) id=284 class=ms-unselectedtitle height="100%"
    cellSpacing=0 Type="" SUrl="" UIS="1024" 
    CId="0x010010381707B6E7FC45825D794C02F54155" CType="Item" MS="0" CSrc="" HCD="" 
    COUId="" OType="0" Icon="icgen.gif||" Ext="" Perm="0x400001f07ee71bef" 
    DRef="sites/site1/M/S/Lists/MAINT_ACTIONS" Url="/sites/site1/M/S/Lists
    /MAINT_ACTIONS/284_.000" CTXName="ctx1" sizset="50" sizcache011076027996994381="6">
          <TBODY beenthere="1">
             <TR>
                <TD class=ms-vb width="100%"><A onclick="GoToLink(this);return false;" 
    onfocus=OnLink(this) href="/sites/site1/M/S/Lists/MAINT_ACTIONS
    /DispForm.aspx?ID=284" target=_self>Item <IMG class=ms-hidden border=0 
    alt="Use SHIFT+ENTER to open the menu (new window)." src="/_layouts/images
    /blank.gif" width=1 height=1></A></TD>
                <TD><IMG style="VISIBILITY: hidden" alt=Edit src="/_layouts/images
    /menudark.gif" width=13></TD>
             </TR>
          </TBODY>
       </TABLE>
    </TD>

关闭的代码如下...

    // filter out all tables with immediate parent td.ms-vb-title
    // returns a collection
    var ids = $('.ms-unselectedtitle').filter(function() {
        return $(this).parent('td').hasClass('.ms-vb-title');

    // from resulting collection, grab all IDs
    }).map(function() {
       return this.id;

    // convert to array
    }).get();

有人可以帮我吗?请注意,我正在尝试从行中的可点击链接访问 ID。

【问题讨论】:

  • 你能发布一些html结构吗?此外,当您说您发布的代码很接近时,这是什么意思。它返回了什么,它应该返回什么?制作Fiddle 是最佳选择。
  • Adam,我已经用代码 sn-p 更新了帖子,直到 ms-vb-title。另外,当我说它关闭时,get() 方法返回列表中的所有 ID。但是我需要它只返回一个 ID,即当前行的 ID。这些行是表 ms-listviewtable 的兄弟,并具有交替名称“”和“ms-alternating”。
  • 所以基本上是在td 内的a 元素的click 事件上,您想获取它所属的td 的ID?
  • 是的,然后 concat 作为带有 url 的结束过滤器,我需要它去。如果我能得到一个可以添加到 .get() 并只返回我需要的数字的 rowIndex 数字。除非有更简单的方法。
  • 好吧,在这种情况下,您只需在点击事件中执行$(this).parent().attr('id')

标签: javascript jquery sharepoint sharepoint-2007


【解决方案1】:

我能够通过在 SharePoint 列表中创建三列以及最后一列将它们放在一起来解决此问题。

    getWin1 held ...onClick='javascript:window.open("... the first part of the
    script and was made default text for this single line text column.

    getWin2 held ...","_blank","toolbar=0,menubar=0,top=50,left=50,width=1024,
    height=800,scrollbars=0,resizable=0,location=0");return false;'... the
    second single line text column.

    getUrl concatenated the url to the ID from the list.

    =CONCATENATE("<span><input ",getWin1,getUrl,getWin2," type='image' 
    src='https://sof.socom.mil/sites/SORDAC/M/SharePoint_System_Files/Icons
    /Magnification_16.png'/></span>")... was put into the last column to
    combine the three columns.

我有 Text to HTML CEWP 可以将其转换为 HTML 脚本。不是最佳解决方案,但它有效。请注意,... 只是标记脚本的开始和结束。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-16
    • 2014-03-19
    • 1970-01-01
    • 2016-09-08
    • 1970-01-01
    相关资源
    最近更新 更多