Editable table add row

Editable table add row

karteekmvskarteekmvs Posts: 3Questions: 0Answers: 0
edited July 2011 in General
Hi,

I am implementing Datatables with editable plugin and I am trying to pre-populate the form when add row button is hit from the selected row of the table. How do I pass the cell values of the selected row to the form?

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    when you click your button, you can get the button's parent cell or parent row

    with a cell or row dom object, you can get it's position in the table with fnGetPosition

    you can get the data for the entire row with fnGetData with the row dom element or an integer index
    look at the aData variable in this code snippet:
    [code]
    $(document).ready(function() {
    $('#example tbody td').click( function () {
    /* Get the position of the current data from the node */
    var aPos = oTable.fnGetPosition( this );

    /* Get the data array for this row */
    var aData = oTable.fnGetData( this );

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

    /* Init DataTables */
    oTable = $('#example').dataTable();
    } );
    [/code]
This discussion has been closed.