gpt4 book ai didi

jquery - Angular Datatables 对超链接内的文本而不是 href 进行排序

转载 作者:行者123 更新时间:2023-11-30 23:44:13 25 4
gpt4 key购买 nike

我正在尝试按字母数字方式对包含 anchor 标记的列进行排序,该 anchor 标记似乎“拦截”了排序功能。它看起来像以下几行:

<tbody>
<tr><td><a href="/1"></a>Fox</td><tr>
<tr><td><a href="/2"></a>Cow</td><tr>
<tr><td><a href="/3"></a>Dog</td><tr>
</tbody>

它将分别返回 Fox,Cow,DogDog,Cow,Fox。如何根据 a 标记的内容而不是 a 标记本身的文本进行排序?

ctrl.dtOptions = DTOptionsBuilder.newOptions()
.withPaginationType('full_numbers')
.withOption("order", [
[1, "asc"]
])
.withOption('paging', false)
.withOption('searching', false)
.withOption("sDom", '<"top">rt<"bottom"flp><"clear">');

ctrl.dtColumnDefs = [
DTColumnDefBuilder.newColumnDef(0).notSortable(),
DTColumnDefBuilder.newColumnDef(1)
];

1:不可排序
2:字母数字(问题栏)
3-10:字母数字 - td 只有数字,因此排序正常

最佳答案

尝试对包含 HTML 的列使用 .withOption('type', 'html'),如下所示:

ctrl.dtColumnDefs = [
DTColumnDefBuilder.newColumnDef(0).notSortable(),
DTColumnDefBuilder.newColumnDef(1).withOption('type', 'html')
];

来自documentation :

html - Basic string processing for HTML tags

Sorting - sorted with HTML tags removed
Filtering - HTML tags removed from filtering string

参见columns.type了解更多信息。

关于jquery - Angular Datatables 对超链接内的文本而不是 href 进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30989674/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com