Datatables Servside Output handling

Datatables Servside Output handling

donnydonny Posts: 2Questions: 0Answers: 0
edited October 2011 in General
I am trying to get Datatables to work with Mysql and PHP.
It is displaying the results but I want some results to be output as a html input box.
Is this possible?

Replies

  • OmnimikeOmnimike Posts: 22Questions: 0Answers: 0
    edited October 2011
    Using fnRowCallback described here http://datatables.net/usage/callbacks you can do whatever you want with a row before it is inserted into the table. It works something like this:
    [code]
    $('#tableId').dataTable({
    //...Other options...
    fnRowCallback: function(tr, data, rowNum, index) {
    $(tr).children().first()
    .empty()
    .append($(''));
    }
    });
    [/code]

    That code (untested) should empty the first td in each row and replace it with an input box with the same value in it (assuming you are using and array of arrays for your data and not an array of objects).

    That's the idea at least. Of course, it's up to you how you are going to get what users put into those boxes and do something useful with it.
  • donnydonny Posts: 2Questions: 0Answers: 0
    edited October 2011
    Thank you! I got it to work using:

    [code]"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
    $('td:eq(0)', nRow).empty().html( '
This discussion has been closed.