Whole row clickable

Whole row clickable

mattclementsmattclements Posts: 7Questions: 0Answers: 0
edited March 2012 in General
Hello there,
I was wondering if the whole row of a Data Table can be clickable...

i.e. at present I have (* Denotes a Link):
Joe | Bloggs | View* Edit*

Ideally I would like any-where on the row to highlight (as it does using CSS now), and clicking anywhere on the row (except the edit link, or the last column I guess) goes to the View link??

Thanks in advance,
Matt Clements

Replies

  • chankl78chankl78 Posts: 13Questions: 0Answers: 0
    This is what I am using & it works for me.

    Version 1 (When "bServerSide": false)
    [code]
    "fnDrawCallback": function () {
    $("#tModuleListing tbody tr").dblclick(function () {
    var position = oTable.fnGetPosition(this); // getting the clicked row position
    RowID = oTable.fnGetData(position); // getting the value of the first (invisible) column
    window.location.href = "Invoice.cshtml?MM=" + RowID[1];
    });

    $('#tModuleListing tbody tr').each(function () {
    this.setAttribute('title', "Double Click to view detail.");
    });
    }
    [/code]

    Version 2 (When "bServerSide": true)
    [code]
    "fnDrawCallback": function () {
    $("#tPaymentListing tbody tr").click(function () {
    var position = opTable.fnGetPosition(this); // getting the clicked row position
    pRowID = opTable.fnGetData(position); // getting the value of the first (invisible) column
    //sessionStorage.setItem("PVID", pRowID.PVID); // HTML 5 Session Storage;
    window.location.href = "PaymentVoucher.cshtml?MM=" + pRowID.PVID;
    });
    }
    [/code]

    Smile
    Chankl78
  • mattclementsmattclements Posts: 7Questions: 0Answers: 0
    Thanks so much - Thats awesome!

    I have actually used:
    [code]
    "fnDrawCallback": function () {
    $(".datatable tbody tr").click(function () {
    var position = oTable.fnGetPosition(this); // getting the clicked row position
    pRowID = oTable.fnGetData(position,0); // getting the value of the first (invisible) column
    //sessionStorage.setItem("PVID", pRowID.PVID); // HTML 5 Session Storage;
    window.location.href = "/member?member_id=" + pRowID;
    });
    }
    [/code]

    Ignore the oTable rather than opTable, and .datatable rather than #tPaymentListing; but I have changed the pRowID = opTable.fnGetData(position); to pRowID = oTable.fnGetData(position,0); to get the initial column straight away, and changed the pRowID.PVID to just pRowID

    Regards,
    Matt
  • chankl78chankl78 Posts: 13Questions: 0Answers: 0
    Thanks!!!..

    I have learn something new...

    Smile
    Chankl78
This discussion has been closed.