1

大家好,我有一个使用 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 }
                ],
            }
        );

你有什么建议吗?

4

2 回答 2

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

于 2014-08-22T16:02:51.550 回答
0

样式应该使用 css 完成:

#myegiftcardstable th { text-align: center }
#myegiftcardstable td { text-align: right }
于 2013-08-13T07:57:55.827 回答