数据表 jQuery TH 和 TD 对齐
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18201133/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
DATATABLE jQuery TH and TD alignment
提问by Emil Re?a Enriquez
hi guys I have a code using jquery.datatable
大家好,我有一个使用 jquery.datatable 的代码
I want the header to be center align and the td to be right aligned, for example and
我希望标题居中对齐,td 右对齐,例如和
my code js
我的代码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?
你有什么建议怎么做吗?
回答by Lucretius
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.
这是有关使用的文档。
回答by LeGEC
Styling should be done using css :
样式应该使用 css 完成:
#myegiftcardstable th { text-align: center }
#myegiftcardstable td { text-align: right }