简体   繁体   English

使用 jQuery DataTables,如何使鼠标光标在可排序的列标题上切换?

[英]With jQuery DataTables, how do I make the mouse cursor change over sortable column headers?

In DataTables examples , I see that the mouse cursor changes to indicate a link when hovering above sortable column headers.DataTables 示例中,我看到鼠标光标在悬停在可排序列标题上方时会发生变化以指示链接。 However, I do not get the same effect in my own project.但是,我在自己的项目中没有得到同样的效果。 I configure DataTables like so (with theming by jQuery UI ThemeRoller):我像这样配置数据表(使用 jQuery UI ThemeRoller 的主题):

$('#build-table').dataTable({
    'aaSorting': [[1, 'desc'], [0, 'asc'], [2, 'asc']],
    'bJQueryUI': true,
    });

How do I get the mouse cursor behaviour, when hovering above sortable column headers, of the DataTables demos?当鼠标悬停在 DataTables 演示的可排序列标题上方时,如何获得鼠标光标行为?

EDIT编辑

I know it's doable with CSS, but wondering if there's anything out of the box as the DataTable demos all work like this.我知道它可以使用 CSS,但想知道是否有任何开箱即用的东西,因为 DataTable 演示都像这样工作。

I'm not familiar with dataTable() specifically, but the easiest way is to give the sortable columns a class and use the CSS cursor:pointer;我对dataTable()不是特别熟悉,但最简单的方法是给可排序的列一个类并使用 CSS cursor:pointer; property to make the mouse indicate it is clickable.属性使鼠标指示它是可点击的。

The datatables demos all use demo_table.css and this rule:数据表演示都使用demo_table.css和这个规则:

table.display thead th {
    padding: 3px 18px 3px 10px;
    border-bottom: 1px solid black;
    font-weight: bold;
    cursor: pointer; /*This is what you want*/
    * cursor: hand;
}

Add following as CSS and you are good to go.将以下内容添加为 CSS,您就可以开始了。

.sorting {
    cursor:pointer;
}
.sorting_asc {
    cursor:pointer;
}
.sorting_desc {
    cursor:pointer;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM