twitter-bootstrap 使用 js 脚本对引导表进行排序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16204935/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sorting a bootstrap table with a js script
提问by Quantico
I am aware that bootstrap took out the ability to sort a table in their 2.0. I was looking online for a solution for my sorting problem and I found the following nice script http://www.kryogenix.org/code/browser/sorttable/
我知道引导程序取消了在他们的 2.0.0 中对表格进行排序的能力。我在网上寻找排序问题的解决方案,我发现了以下不错的脚本 http://www.kryogenix.org/code/browser/sorttable/
The issue that I am having right now is that the arrows (for sort in a ascending/ descending order) are not appearing right away, only after the user clicks once on the table they will appear. But the user will never know he or she can click to sort without seeing an icon to begin with.
我现在遇到的问题是箭头(按升序/降序排序)不会立即出现,只有在用户在表格上单击一次后才会出现。但是用户永远不会知道他或她可以在没有看到图标的情况下点击排序。
I played with this part that has to do with the icons.
我玩过这部分与图标有关的部分。
sortfwdind.innerHTML = '<span class="ui-icon ui-icon-triangle-1-s"></span>';
sortfwdind.className = "ui-icon ui-icon-triangle-1-s";
But i could not make it present an initial icon before the first click. Any suggestions?
但是我无法在第一次点击之前让它呈现一个初始图标。有什么建议?
采纳答案by ricardohdz
That library is using pure HTML to insert the row after the table header. Look for:
该库使用纯 HTML 在表头之后插入行。寻找:
sortrevind.innerHTML = stIsIE ? ' <font face="webdings">5</font>' : ' ▴';
in the source code. You may want to just add ' ▴'after each table header (to have the arrow before first click) and then edit its innerHTML and delete that icon in the click event.
在源代码中。您可能只想' ▴'在每个表标题之后添加(在第一次单击之前有箭头),然后编辑其 innerHTML 并在单击事件中删除该图标。
回答by sil
See http://www.kryogenix.org/code/browser/sorttable/#symbolsbeforesortingin the sorttable documentation for one way to do this.
有关执行此操作的一种方法,请参阅sorttable 文档中的http://www.kryogenix.org/code/browser/sorttable/#symbolsbeforesorting。

