id of highlighted row

id of highlighted row

snigdhasnigdha Posts: 2Questions: 0Answers: 0
edited February 2014 in General
how can i get id of the highlighted row and send it to controller to update status of the that record in database without using json object means as a simple java object.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited February 2014
    How are you highlighting the row? If using a jQuery click event handler, just use `this.id` .

    Allan
  • ashiersashiers Posts: 101Questions: 8Answers: 7
    edited February 2014
    Typically you would use TableTools to add a button to start. Then you use the click event on the button to capture the id of a selected row, like this:
    [code]
    {
    "sExtends": "text",
    "sButtonText": "View Ads",
    "fnClick": function()
    {
    var ID = "";
    var selectedRows = this.fnGetSelected();
    if(selectedRows == "")
    {
    alert("No record has been selected");
    return;
    }
    var firstId = selectedRows[0].id;
    //remove the "row_" prefix
    ID = firstId.substring(4,firstId.length);
    window.location.href = "Ads.jsp?id=" + ID;
    }
    }
    [/code]

    In this case, every record has an ID column where each ID is prefixed with "row_" string. In this code I'm stripping away the prefix just to get the numeric value and passing that onto a JSP page which performs a lookup on the database and displays more info.

    Since you're on the Java platform, I suggest you visit the JED website. JED was designed to demonstrate how DataTables is used on the Java platform.
    Check it out: http://jed-datatables.ca/jed/
This discussion has been closed.