0

I started playing with jQuery Datatables Plugin and got the table/cell change from display text to a textbox when user click on the display text. Now, my next step is to save this information on the database record after user edited the value in the cell.

This is my code for the editable table.

/* Init DataTables */
var oTable = $('#tblAmount').dataTable({
    "bPaginate": false,
    "bFilter" : false,
    "bInfo" : false
});

/* Apply the jEditable handlers to the table */
oTable.$('td').editable( 'ajaxUpdateAmount.asp', {
    "callback": function( sValue, y ) {
        var aPos = oTable.fnGetPosition( this );
        oTable.fnUpdate( sValue, aPos[0], aPos[1] );
    },
    "submitdata": function ( value, settings ) {
        return {
            "row_id": this.parentNode.getAttribute('id'),
            "column": oTable.fnGetPosition( this )[2]
        };
    },
    "height": "14px",
    "width": "100%"
} );

The table like this below:

 <table cellpadding="0" cellspacing="0" border="0" class="display" id="tblAmount">
    <thead>
      <tr>
        <th>RecordID</th>
        <th>Amount</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>123</td>
        <td>$1,000</td>
      </tr>
    </tbody>
</table>

Any advice about:

1) How to send the recordID to the ajax page?

2) How to actually see the ajax page updating after the value change in the cell? maybe display in the DIV or something?

Please provide a sample code if possible.

Thank you,

5
  • Can you provide a sample of what you have tried? Commented Apr 30, 2014 at 16:35
  • I am stuck right there, I don't know who to see my value that sends to the Ajax so I go further. Commented Apr 30, 2014 at 16:38
  • Check here - stackoverflow.com/questions/18846999/… Commented Apr 30, 2014 at 16:43
  • Thanks Jay, but that doesn't help much. I want to know how to send the current updating recordID to the Ajax page, and also help to see the Ajax page is updating ... Commented Apr 30, 2014 at 16:55
  • Anyone knows how to send the RecordID and text that is being edited? Example, when I change from $1000 to $2000, how do I send both RecordID(123) and the new Amount($2000) to the Ajax page in the background to update the record? Commented Apr 30, 2014 at 17:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.