给每个TD定制课程用于样式 - Datatables& jQuery [英] Giving custom classes to each TD for styling - Datatables & jQuery

查看:144
本文介绍了给每个TD定制课程用于样式 - Datatables& jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用数据表在表格中显示服务器端数据。

I'm using datatables for displaying server-side data in tables.

虽然我无法定位和样式单个单元格(< TD> )。我搜索一下,发现可能是:

I can't target and style individual cells (<TD>) though. I search a bit and found it might be possible with:

"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
    ....
}

...但我不是确定如何,因为我有几个表,并不是都有相同数量的列和行。我想为'列'的所有 TDs 提供公共类。

... but I'm not quite sure how because I have a few table and not all have the same number of columns and rows. I want to give common class to all TDs of a 'column'.

推荐答案

您可以在列定义中使用 sClass 参数。例如,如果您有3列,并希望通过第二和第三列的自定义类,您可以:

You can use sClass parameter in Columns definition. For example, if you have 3 columns and want to pass custom class for second and third column, you can:

"aoColumns": [
    null,
    { "sWidth": "95px", "sClass": "datatables_action" },
    { "sWidth": "45px", "sClass": "datatables_action" }
]

您可以查看数据表文档

这篇关于给每个TD定制课程用于样式 - Datatables&amp; jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆