When I use server-side script I can't chose what class the rows will have. The table is always draw with the standard TR class, I'd like then to have class gradeA like I wrote in the code:
I haven't actually done anything with server-side processing yet, but I'm pretty sure you should be able to use the 'fnRowCallback' to modify your rows: http://datatables.net/usage/callbacks#fnRowCallback.
all you would need to do is something like:
[code]
$(document).ready(function() {
$('#example').dataTable( {
...
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$(nRow).addClass('gradeA');
return nRow;
}
} );
} );
[/code]
You'll need to call .editable() every time you make a draw because DataTables is making new DOM elements that weren't there the last time you called .editable()
Replies
I haven't actually done anything with server-side processing yet, but I'm pretty sure you should be able to use the 'fnRowCallback' to modify your rows: http://datatables.net/usage/callbacks#fnRowCallback.
Hope that helps
Thanks for the help.
[code]
$(document).ready(function() {
$('#example').dataTable( {
...
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$(nRow).addClass('gradeA');
return nRow;
}
} );
} );
[/code]
Thanks a lot for the help.
Any chance for TD class? I'm using TD class for jeditables and TR class doesn't work for me.
Thanks in advance.
$(document).ready(function() {
$('#example').dataTable( {
...
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td:eq(2)', nRow).addClass('gradeA');
return nRow;
}
} );
} );
[/code]
Sorry, forgot to mention I'm using AJAX as data source and trying to set TD class, so that I can use Jeditables for inline editing.
Pls help.
[code]
$(document).ready(function() {
var oTable = $('#table_id').dataTable( {
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "select.asp",
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td:eq(2)', nRow).addClass('class_edit');
return nRow;
}
} );
$('.class_edit', oTable.fnGetNodes()).editable( 'update.asp', {
indicator : 'Saving...',
tooltip : 'Click to edit...',
...
[/code]
[code]
$(document).ready(function() {
var oTable = $('#table_id').dataTable( {
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "select.asp",
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td:eq(2)', nRow).addClass('class_edit');
return nRow;
},
"fnDrawCallback": function () {
$('.class_edit', oTable.fnGetNodes()).editable( 'update.asp', {
indicator : 'Saving...',
tooltip : 'Click to edit...',
...
}
}
} );
$('.class_edit', oTable.fnGetNodes()).editable( 'update.asp', {
indicator : 'Saving...',
tooltip : 'Click to edit...',
...
[/code]
I used to be able to save the changes back to database, when it's without server side processing & AJAX source, but not I can't.
Tried moving "callback" and "submitdata" out of "fnDrawCallback", but it doesn't help as well.
Any advise?
[code]
$(document).ready(function() {
var oTable = $('#table_id').dataTable( {
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "select.asp",
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td:eq(1)', nRow).addClass('class_edit');
return nRow;
},
"fnDrawCallback": function () {
$('.class_edit', oTable.fnGetNodes()).editable( 'update.asp', {
indicator : 'Saving...',
tooltip : 'Click to edit...',
onblur: 'submit',
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1], false, true );
},
"submitdata": function ( value, settings ) {
return {
"row_id": this.parentNode.getAttribute('id'),
"column": oTable.fnGetPosition( this )[2]
};
},
"height": "14px"
} );
}
} );
} );
[/code]
Thanks a million for your tips!!!