- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含两个标题行的表格。这些列是成对的——一列有简短的描述,另一列有详细的描述。第一个标题行在每列中简单地表示“扩展”或“收缩”。当用户单击第一个标题行中的“展开”(或“收缩”)时,JavaScript 将切换具有短描述和长描述的列。
第二个标题行包含每列的名称。
我希望当用户单击第二个标题行时对表格进行排序,但当用户单击第一个标题行时不进行排序。当他单击第一个标题行时,它应该显示/隐藏正确的列,但不排序。
如果我将第一个标题行中的单元格的类设置为“sorter-false”,我就可以实现此目的。
问题就在这里。我使用 addParser 添加了一个解析器。每个单元格都有一个名为“data-sort-value”的属性。然后我调用 $(table).tablesorter() 并传递每列的 headers 参数 - 就像这样 -
$("#tbl").tablesorter({
theme: 'myTheme',
headers: {
0: { sorter: 'myparser' },
1: { sorter: 'myparser' },
2: { sorter: 'myparser' },
3: { sorter: 'myparser' },
4: { sorter: 'myparser' }, etc.
当列被分配为“myparser”时,“sorter-false”类不再阻止排序。
如果列有解析器,有什么方法可以让它不对第一个标题行单元格进行排序?
最佳答案
我认为这不适用于原始版本的 tablesorter。它将忽略第二个标题行。
但是,如果您使用我的 fork of tablesorter ,您可以按如下方式设置( demo ):
HTML
<table class="tablesorter">
<thead>
<tr>
<th class="sorter-false">AlphaNumeric</th>
<th class="sorter-false">Numeric</th>
<th class="sorter-false">Animals</th>
<th class="sorter-false">Sites</th>
</tr>
<tr>
<th class="sorter-myparser">AN</th>
<th>N</th>
<th>An</th>
<th>S</th>
</tr>
</thead>
<tbody>
<tr>
<td data-sort-value="abc 123">abc 123</td>
<td>10</td>
<td>Koala</td>
<td>http://www.google.com</td>
</tr>
...
</tbody>
</table>
脚本
$(function () {
$.tablesorter.addParser({
// use a unique id
id: 'myparser',
is: function () {
return false;
},
format: function (s, table, cell, cellIndex) {
return $(cell).attr('data-sort-value');
},
// flag for filter widget (true = ALWAYS search parsed values;
// false = search cell text)
parsed: true,
type: 'text'
});
$('table').tablesorter({
theme: 'blue'
});
});
实际上,如果这就是您的解析器所做的一切...在最新版本中,您可以设置 textAttribute
option并在没有自定义解析器的情况下完成同样的事情( demo ):
$(function () {
$('table').tablesorter({
theme: 'blue',
textAttribute: 'data-sort-value'
});
});
关于Jquery tablesorter addParser 两个标题行 sorter-false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23161826/
我在使用 JQuery table-sorter plugin 时遇到了一些问题。 我的 HTML 结构非常简单,我只是调用该函数(尝试所有表和带有 .tablesorter 类的表),但似乎没有任何
所以基本上,我在大学学习用 Java 编码,我已经上了第一个类,现在我面临的挑战是用 if 和 while 制作一个“硬币分类器”程序。该计划的目标是向其提供一定数量的欧元资金,并以最有效的方式组织返
我正在尝试使用最新可用的 Jquery 表排序器插件。 http://mottie.github.com/tablesorter/docs/#Demo 问题是我有一个日期格式的表列,并且它还包含一个电
即使在@Tabulator 站点给出的示例中也是如此: http://tabulator.info/basic/4.2 与其他列不同,日期列不排序。有解决办法吗? 最佳答案 Tabulator 的日期
引用表排序器 2.0: http://mottie.github.io/tablesorter/docs/index.html 我没有使用 Table Sorter 2.0 的内置过滤器。我实际上必须
我有一个包含两个标题行的表格。这些列是成对的——一列有简短的描述,另一列有详细的描述。第一个标题行在每列中简单地表示“扩展”或“收缩”。当用户单击第一个标题行中的“展开”(或“收缩”)时,JavaSc
我正在使用 jQuery 的 tablesorter 插件在客户端对我的 gridview 进行排序。但这是问题,我必须使该排序选项仅适用于一列。 (gridview中列号为7) $("#").ta
我想知道是否有一种方法可以使用表排序器对列进行排序 这样我就可以根据某个 ID 或其他内容自行排列列。 例如,如果我想对表进行排序,以便 Apple 列 首先,我该怎么做? 最佳答案 演示: http
我认为这应该可以正常工作...我不确定它出了什么问题?这是我的代码片段。如果给定的整数列表不是按升序排列,则假定返回 0;如果按升序排列,则返回 1。 struct Node{ int da
我正在使用 tablesorter 对表格内容进行排序。我的表格如下。 No Distance Diagnostic Fee
我正在尝试创建一个从不同类型的排序静态继承的排序方法类。意思是根据排序选择的类型,sortmethods继承它的成员。我真的不擅长使用模板。 我已经尝试使用可变参数模板,模板的模板,但我仍然无法修复它
我的项目中有搜索字段,它使用 $.post 获取搜索查询的结果。我的问题:当用户单击搜索按钮时,它可以正常工作,但是当用户再次单击搜索按钮,然后单击我的 thead 列时,jquery sorter
我有一个需要应用排序的表。我正在使用 knockout 和 jquery.tablesorter.js。我也尝试过自定义绑定(bind),但没有帮助。如果没有 knockout ,我的代码可以正常工作
tablesorter 插件似乎存在问题,并且排除了用于排序的列。在文档中:http://tablesorter.com/docs/example-meta-headers.html您可以向 th 添
我正在使用 Jquery 表排序器对我的数据进行排序。目前,当使用 jquery 表排序器加载此数据(PHP/MySQL)时,我的数据库表有超过 3000 行,页面变得更慢,我该怎么办,我正在使用 j
我正在使用jQuery tablesorter plugin 。它似乎工作正常,只是它无法对以图像标签作为内容的行进行排序。我想实现一些仅按图像标签的 src 属性排序的东西。我尝试了很多方法,但似乎
我的应用程序使用 jQuery + Tablesorter (mottie fork) 创建服务器概览表。 我使用 Bootstrap 主题 ( theme.bootstrap.css ) 并在 ta
我有一张 table ,可以说 id name 1 Sam 2 Alex
我有一个带有缓冲存储的 EXTJS 网格。我在这家商店启用了 remoteSort: true。一些列被标记为可排序:真。但是每次我点击任何列进行排序时,进行的后端调用只包括商店中提到的排序列和方向。
我是一名优秀的程序员,十分优秀!