ServerSide processing and local update of a single row W/O doing an ajax call

ServerSide processing and local update of a single row W/O doing an ajax call

kktoskktos Posts: 11Questions: 0Answers: 0
edited December 2011 in General
I'm struggling a bit on that.

I have a datatable with server side processing. I have the possibility to edit some values and to post them to the server.
I wish then to refresh the modified row with the updated data for the row without
-1- redrawing the whole table
-2- regeting the data from the server

I tried to play a bit with fnUpdate but the guy is calling fnReDraw so I'm busted.

Any suggestion'r welcomed
cheers
/tm

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    you can set a parameter in fnUpdate to not call fnDraw. have you tried this?
  • kktoskktos Posts: 11Questions: 0Answers: 0
    yep. but I need my row to be redrawn. the data is numerical, the representation done in fnRender is graphical.
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    edited December 2011
    I think you're saying you want to update the data (fnUpdate), then have fnRender run again to process it?

    here's a hack-ish way you can re-trigger fnRender after fnUpdate'ing the data (run this for every TD in the row):

    note: the way i have it written relies on a global "oTable" variable. if you don't use a global, just rewrite the params to require oTable or retrieve oTable yourself with a call to .dataTable()

    [code]
    // repaint a cell with its column's render function
    function fnRepaint(nTd) {
    if (typeof nTd === "undefined") nTd = this;

    // get internal index pointer to data in DataTables for this TD element
    var aPos = oTable.fnGetPosition( nTd );
    var iRow = aPos[0];
    var iCol = aPos[1];

    // get the Column object representing the column this TD belongs to
    var oSettings = oTable.fnSettings();
    var oCol = oSettings.aoColumns[iCol];

    // if the column has a render function, call the function
    if (typeof oCol.fnRender === "function") {
    var oData = oSettings.aoData[iRow]._aData;
    var oObj = {
    iDataRow: iRow,
    iDataColumn: iCol,
    aData: oData
    }

    nRow = oTable.fnGetNodes(iRow);
    $('td', nRow).eq(iCol).html(oCol.fnRender(oObj));
    }

    // turn off processing message
    $('.dataTables_processing').hide();
    }
    [/code]
  • kktoskktos Posts: 11Questions: 0Answers: 0
    edited December 2011
    thx fbas. That's a start. I'm still trying to figure out what will be the right path to follow.
    btw, in your code, line 24, you should prefer the following selector:
    $('>td',nRow)
    in order to have only the dataTable TD, not the ones that may be in the cell (as I have ;))
    thx very much for ur help
This discussion has been closed.