columns样式 jquery,如何更改JQuery.DataTable中单元格的样式?

I have a question about setting the style attributes for a data cell in the jQuery.DataTable. I was able to set the width for each column when initializing the dataTable using the following code:

oTable = $('#example').dataTable( {

"aoColumns" : [

{ sWidth: '40%' },

{ sWidth: '60%' }

]

} );

Now I want to change the alignment for the second column like so: style="text-align: right;".

I am adding rows dynamically using this code:

/* Global var for counter */

var giCount = 2;

function fnClickAddRow() {

oTable.fnAddData( [

'col_1',

'col_2' ] );

giCount++;

}

Can you tell me how can I select the second cell of the new row after it's been inserted OR how to set the style of the row before/during insertion?

Any help would be greatly appreciated!

解决方案

Cool, I am happy to report that I was able to answer my own question! I just defined a CSS style (alignRight), and added the style to the column like so:

.alignRight { text-align: right; }

oTable = $('#example').dataTable( {

"aoColumns" : [

{ sWidth: '40%' },

{ sWidth: '60%', sClass: "alignRight" }

] } );

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值