Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
405
How to get row data from the data view when you have the DOM tr element
posted

Using a js library jsPlumb which establishes connections between grid tr elements. I get a list of connections and from those I can get the tr element at each end of the connection (think of two grids in a work area with a connection between them that indicated the relationship).

The igGrid is created with three columns but only one column is ever displayed at a time (the user can choose to show any of the columns but only one). The first column is the data I need. So if its the column displayed I can get the data easy enough as it is just in the td. That is I just do a,

var trElement = connection.endpoints[0].getElement(); // returns the DOM tr element
alert("trElement.find("td").html()"); // displays the text for the currently displayed column

However, the user may have one of the other two columns displayed instead, so I need to get the data for the cell in the first column that is now hidden. I tried the following:

trElement.attr("data-id");

But that is undefined. If I have the DOM tr element. How can I get the row data?

Thanks,

Pat


  • 23953
    Verified Answer
    Offline posted

    Hi Pat,

    The best way to accomplish this is to set primaryKey on the grid and then use igGrid.findRecordByKey method.

    The "data-id" attribute will be available only if you set primaryKey on the grid. I guess you didn't set it. That's why it is undefined in your case.

     

    Best regards,
    Martin Pavlov

    Infragistics, Inc.