数据表 - 表的自定义样式

时间:2016-08-06 06:57:18

标签: jquery css database datatables export-to-pdf

我正在使用数据表。我在pdf中导出table。如何为pdf中导出的table应用自定义样式?

这是我的代码:

table = $(tableId).DataTable({
            dom: 'frtip',
            ajax: 'https://api.myjson.com/bins/qgcu',
            ordering: false,
            searching:false,
            buttons: [
              {
                 extend: 'collection',
                 text: 'Export',
                 buttons: [ {
                     extend: 'pdf',
                     filename : fileName,
                     title : rprtTtl,
                     orientation: "portrait",
                     pageSize : "LETTER",
                     defaultStyle: {
                         margin: 'auto',
                    },
                    customize: function (win) {
                        console.log(win);
                        $(table)
                             .css('margin', 'auto')

                        }
                 },
                 {
                     extend: 'excel',
                     filename : fileName,
                     title : rprtTtl,
                     orientation: "landscape",
                     pageSize : "A3"
                 }]
              }
           ]
        });

实际上在pdf中我的tablealigned left。我想align table center css。如何为此应用自定义public $paginate =[ 'limit' => 10, 'order' => [ 'tble.id' => 'asc' ] ]; public function initialize() { parent::initialize(); $this->loadComponent('Paginator'); } public function index() { $product = TableRegistry::get('tble'); $query = $product->find(); $this->set(array('data'=>$query)); $this->set('tble', $this->paginate($query)); $this->render('index'); }

0 个答案:

没有答案