using fnRowCallback and fnServerData giving warning
using fnRowCallback and fnServerData giving warning
mayurpatel
Posts: 10Questions: 0Answers: 0
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
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
This discussion has been closed.
Replies
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
it would be huge help.
Thanks
Mayur
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
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
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
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
Allan