Question

I need to extract the ID from ms-unselectedtitle which is a child element of ms-vb-title in a SharePoint 2007 list. This would then be concatenated with a url to open a new window. The window needs to open with the window.open() method so i can control the size and turn off menus. Creating a link in the list by calculated column won't work as it just opens a new window in a tab with all menus. I found code here ("How to get ID value from tables nested in other tables with jQuery") that is close but it returns an array of ID's, not by table row. I'm new to javascript/jquery so I'm a bit stuck. Note that the ID I'm using is embedded in the "Title" field of the list. Html section is here...

    <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>

The code that is close is below...

    // 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();

Could someone help me here? Note that I'm trying to access the ID from a clickable link in the row.

Était-ce utile?

La solution

I was able to resolve this by creating three columns in the SharePoint list with a final one to put them together.

    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.

I have Text to HTML CEWP to convert it to HTML script. Not the optimal solution but it works. Note that the ... just marks the start and end of the script.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top