get the selected row value

get the selected row value

jobybaztyjobybazty Posts: 39Questions: 0Answers: 0
edited June 2012 in General
Hi,
I have added datatable in my list and in each row, there is a button. I want to get a value from the clicked buttons row. please help me to find a solution for this

Replies

  • koosvdkolkkoosvdkolk Posts: 169Questions: 0Answers: 0
    On http://datatables.net/ref, check the fnGetData function. You can feed this function the 'tr'-element, and it spit out its data :)
  • jobybaztyjobybazty Posts: 39Questions: 0Answers: 0
    Hi,
    Thank you for your reply and time spent to read my request. I did as per the example. But, i m geting null as result.

    $('#servsallist').append('Doc No    EC No          Action ');
    oTable = $('#servsallist').dataTable({
    "bLengthChange": false,
    "bPaginate": false ,
    "aaSorting": [[ 0, "desc" ]]
    });
    $('input[type="button"]').click(function ()
    {
    alert("clicked ...");
    /* Get the position of the current data from the node */
    var sData = oTable.fnGetData( this );
    alert("========= "+sData);
    var aPos = oTable.fnGetPosition(this);
    alert("aPos ..."+aPos);
    /* Get the data array for this row */
    var aData = oTable.fnGetData( aPos[0] );

    /* Update the data array and return the value */
    aData[ aPos[1] ] = 'clicked';
    this.innerHTML = 'clicked';
    });

    });

    This is the code I am using.

    Regards,

    Joby Joseph
  • koosvdkolkkoosvdkolk Posts: 169Questions: 0Answers: 0
    edited June 2012
    Could you please post your code in http://live.datatables.net/#javascript,html,live?

    Makes live much easier ;)
  • jobybaztyjobybazty Posts: 39Questions: 0Answers: 0
    Hi Mr. koosvdkolk,

    I have posted the code and it is in the link
    http://live.datatables.net/ofodif/3/edit#source
    please check this. i am not getting the oTable.fnGetData( this ) value
  • koosvdkolkkoosvdkolk Posts: 169Questions: 0Answers: 0
    http://live.datatables.net/ofodif/4/edit

    replaced $('table th') with $('table tr')

    Is this what you were looking for?
  • jobybaztyjobybazty Posts: 39Questions: 0Answers: 0
    Thank you Mr. koosvdkolk . It works....... :)
This discussion has been closed.