I have retrieved table from SQL procedure contains column with name of class that is to be applied on that particular row.
However that table is passed to datatable.js as a data-source.
Now with my code, specified class is getting applied to only one cell: in fnRowCallback() function.
I want is to apply that class to entire row.
Here is my javascript code:
var dataSet = JSON.parse("[" + a.toString() + "]")
$(document).ready(function () {
$('#demo').html('<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table>');
$('#example').dataTable({
"data": dataSet,
"columns": [
{ "title": "Center" },
{ "title": "Call Executive" },
{ "title": "Name" },
{ "title": "Mobile" },
{ "title": "Phone" },
{ "title": "Status" },
{ "title": "Appt Date" },
{ "title": "Joined Date" },
{ "title": "Remark" },
{ "title": "Source" },
{ "title": "Publisher" },
{ "title": "css" },
]
,
"fnRowCallback": function (nRow, aData, iDisplayIndex) {
if (aData["css"] == "gradeC") {
$(nRow).addClass('gradeC');
}
else {
$(nRow).addClass('gradeN');
}
}
});
});
Sample Datatable string (class is specified in last column) passed to function is:
var dataSet = ['Dadar', 'lmsSenitaD', 'Atul salaskar', '9876543210', '', 'Not Joined', '10/01/2014', '', 'Come back and Join', 'Mobile', 'Times','gradeC'],
['Aundh', 'Rashmi', 'Preeti Gupta', '9876543210', '', 'Not Joined', '10/01/2014', '', 'Will Discuss with Family', 'Online Campaign', 'Iksula','gradeN'],
['Do@Home_Thane', 'Rashmi', 'Mitali Gupta', '9876543210', '', 'Joined - Old Date', '10/01/2014', '20/08/2014', 'Come back and Join', 'Online Campaign', 'Iksula','gradeC'];
fnRowCallbackso the problem must be in the data. Can you addConsole.log(aData['css'])to confirm that the correct data is returned?