using fnRowCallback and fnServerData giving warning

using fnRowCallback and fnServerData giving warning

mayurpatelmayurpatel Posts: 10Questions: 0Answers: 0
edited July 2013 in General
Hello,

I have used fnServerData function for paging. but when I used fnRowCallBack function to add some HTML element in TD element of row I am getting this warning "DataTables warning A node was not returned by fnRowCallback " here is my code

[code]

var oTable = $('#' + listTableId).dataTable({
"bProcessing": true,
"bServerSide": true,
"bFilter": false,
"aoColumnDefs": columnOptions,
"bStateSave": true, // enable state saving true
"iCookieDuration": 60 * 60 * 24 * 365 * 100, // cookie expiration time
"sCookiePrefix": "USER_" + currentLoggedInUserName + "_", // Set cookie prefix with current logged in username
"sAjaxSource": 'Default.aspx/Get',
"fnServerData": fnDataTablesPipeline,
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
/* Append the grade to the default row class name */
if (aData[4] == "A") {
$('td:eq(4)', nRow).html('A');
}
}

});
[/code]

I want to process each row ( to add HTML element TS element ) before table draw. I am using 1.7.3 version of datatable.js

How can I resolve this ??

Thanks

Replies

  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    edited July 2013
    Return the node :-)

    Just add `return nRow;` .

    Newer versions don't require the node to be returned and just use the host row if undefined is returned, but you are using a very old version there which doesn't support that.

    Allan
  • mayurpatelmayurpatel Posts: 10Questions: 0Answers: 0
    edited July 2013
    Sorry Allan I can't get you. can you please explain me again where should I add the nRow in above code ??

    it would be huge help.

    Thanks
    Mayur
  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    At the end of fnRowCallback - return nRow.

    Allan
  • mayurpatelmayurpatel Posts: 10Questions: 0Answers: 0
    OK Thanks !! Allan..

    I have implemented pipelining to reduce the AJAX call for pagination.

    On Delete functionality I have used fnDeleteRow to delete the row from dataTable.

    but it is not working well it is go to previous page for e.g if Table displaying 10 to 20 row outof 100 if I delete 19th Row . then it does not remove the row & showing 1- 10 record on table..

    I was working well before I have implemented paging & pipelining using serverside AJAX call

    Thanks
    Mayur
  • mayurpatelmayurpatel Posts: 10Questions: 0Answers: 0
    edited July 2013
    Hello Allan !

    can you please suggest a solution of my problem ?? if I put the alert in below DeleteRow function than it will send the request to serverside & ROW is deleted from datatable. if I remove the alert then it will not send the request on server side & also row is not deleted from table.

    [code]
    function DeleteRow(row) {
    var oTable = $('#' + TableId).dataTable();
    alert("hi");
    oTable.fnDeleteRow(row);
    }

    function ApplyDataTable() {
    try {

    var oTable = $('#' + TableId).dataTable({
    "bProcessing": true,
    "bServerSide": true,
    "bFilter": false,
    "aoColumnDefs": columnOptions,
    "bStateSave": true, // enable state saving true
    "iCookieDuration": 60 * 60 * 24 * 365 * 100,
    "sCookiePrefix": "USER_" + username + "_",
    "sAjaxSource": 'default.aspx/Get',
    "fnServerData": fnDataTablesPipeline,
    "fnRowCallback": function(nRow, aData, iDisplayIndex) {
    /* Append the TD element set edit / delete link */
    var id = $('td:last', nRow).html();

    var action = '';
    if (EditAllowed) {
    action += '' +

    'Edit ';
    }
    if (DeleteAllowed) {

    action += '' +
    '' +
    'Delete';
    }
    '';

    $('td::last', nRow).html(action);
    return nRow;
    }

    });
    }
    catch (err) {

    }
    }

    [/code]

    Thanks
    Mayur
  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    fnDeleteRow is useless with server-side processing since it is a client-side action. You need to make an Ajax call to the server to delete the row and then call fnDraw to redraw the table. YOu'll also need to clear the pipelinging cache since obviously, it has been invalidated.

    Allan
  • mayurpatelmayurpatel Posts: 10Questions: 0Answers: 0
    edited July 2013
    Thanks Allan !!

    It's working as expected.

    can I set "bPaginate": true based on iTotalRecords return by ajax call on fnServerData callback ?? Means I want to set pagination if total record (iTotalRecords) is more than 10 after ajax call is completed.

    Mayur
  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    Currently no - there is no ability to dynamically enable and disable features. However, it is easy to show / hide the pagination controls based on the number of records in the table. This blog post describes how that might be done: http://datatables.net/blog/Creating_feature_plug-ins

    Allan
  • mayurpatelmayurpatel Posts: 10Questions: 0Answers: 0
    Thank you Allan....

    I have one question.. I am using jtemplate to create HTML element based on the JSON response.
    earlier I have used used datatable() method after I have processed response using the jtemplate create the HTML table

    Now I have implemented server side processing for paging where I need to returned array of column data in json format.. so my question is it possible append tbody HTML element (created by the jtemplate) in fnserverdata callback function

    Mayur
  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    Currently no. The data returned by the server must be in JSON format, not HTML.

    Allan
This discussion has been closed.