Reputation: 2961
hi guys I have a code using jquery.datatable
I want the header to be center align and the td to be right aligned, for example and
my code js
var myegiftcardstable = $j('#myegiftcardstable').dataTable(
{
"bAutoWidth": false,
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": "<?php echo $this->getUrl('myegiftcard/egiftcard/getMyEGiftCards') ?>",
"iDisplayLength": 10,
"bSearchable": false,
"bSortable" : true,
"bFilter": true,
"bLengthChange": false,
"sPaginationType": "full_numbers",
"aoColumns": [
{ "sName": "prod_name"},
{ "sName": "egiftcard_code" },
{ "sName": "price" ,"sClass": "a-right"},
{ "sName": "is_redeemed" , 'bSortable' : false},
{ "sName": "date_redeemed", "sClass": "width_120 " },
{ "sName": "action",'bSortable' : false }
],
}
);
do you have any suggestion how to do that?
Upvotes: 1
Views: 26917
Reputation: 1049
Sorry this response is a year late, but I did find an answer that works for me.
var myegiftcardstable = $j('#myegiftcardstable').dataTable(
{
"bAutoWidth": false,
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": "<?php echo $this->getUrl('myegiftcard/egiftcard/getMyEGiftCards') ?>",
"iDisplayLength": 10,
"bSearchable": false,
"bSortable" : true,
"bFilter": true,
"bLengthChange": false,
"sPaginationType": "full_numbers",
"aoColumns": [
// Column index begins at 0
{ "sClass": "a-right", "aTargets": [ 2 ] },
{ "sClass": "width_120", "aTargets": [ 3 ] }
],
}
);
Here is the documentation on usage.
http://legacy.datatables.net/usage/columns
Upvotes: 3
Reputation: 51780
Styling should be done using css :
#myegiftcardstable th { text-align: center }
#myegiftcardstable td { text-align: right }
Upvotes: 0