Search code examples
jquerysharepointdataformwebpart

Using jQuery to find selected row in a dataFormWegbPart


I have a sharepoint page with 2 dataformwebparts on it. Selecting the first, filters the second. That all works great but now I need to find out what row is selected in the first so that I can add an ID parameter (taken from the first column) to a URL when the user clicks on a button. In other words to allow the next page to know the ID of what was selected in the first dataformwebpart.

My problem is I have no idea how to find out what is selected. I have tried to add some conditional formatting on the selected row to change the font to bold, then use jQuery to find the row with this inline style, but that doesn't seem to work in IE (works in Firefox!).

Has anyone got any idea how to find the selected row, client side?

Thanks


Solution

  • OK, a night thinking about this has given me a solution. I have no idea why the above jQuery doesn't work in IE but the workaround below is a bit cleaner anyway.

    What I have done is to :

    1) Add a new column to the grid and put a "tick" image in it. 2) Set conditional fornmatting on the item so that the img is only displayed for the current Item 3) changed the jQuery selector to look for the image. var id= $("img[name=Tick]").closest('tr').find('td:eq(1)').text();