DATATABLE jQuery TH和TD对齐

时间:2013-08-13 05:10:16

标签: jquery datatable

大家好我有一个使用jquery.datatable的代码

我希望标题居中对齐,td要右对齐,  例如和

我的代码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 }
                ],
            }
        );

你有什么建议怎么做吗?

2 个答案:

答案 0 :(得分:3)

对不起,这个回复是晚了一年,但我找到了一个对我有用的答案。

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 ] }
                ],
            }
        );

以下是有关使用的文档。

http://legacy.datatables.net/usage/columns

答案 1 :(得分:0)

样式应该使用css:

完成
#myegiftcardstable th { text-align: center }
#myegiftcardstable td { text-align: right }