简体   繁体   English

bootstrap-table:禁用对行的排序

[英]bootstrap-table: disable sorting on a row

Is there any way to disable sorting on a specific row using the bootstrap-table library? 有什么方法可以使用bootstrap-table库禁用特定行的排序吗? The reason is my last row is a "Totals" row and I obviously want that to be the last row in every situation. 原因是我的最后一行是“总计”行,我显然希望在每种情况下都将其作为最后一行。

http://jsfiddle.net/e3nk137y/11389/ http://jsfiddle.net/e3nk137y/11389/

It looks like this functionality is incorporated into this bootstrap-sortable library by setting the data-disable-sorting attribute to true on the <tr> element you want to disable ( here ). 它看起来像这样的功能合并到这个bootstrap-sortable 通过设置data-disable-sorting属性true的上<tr>要禁用(元素在这里 )。 Perhaps it's best to use this library on top of bootstrap-table if this isn't available in bootstrap-table ? 也许这是最好的使用这个库的顶部bootstrap-table ,如果这是不具备的bootstrap-table

Figured this out. 想通了。 You can't disable sorting on any specific row (at the moment); 您目前无法在任何特定行上禁用排序; however, you can add a footer row which locks it in to the bottom most row at all times. 但是,您可以添加页脚行,始终将其锁定在最底部的行中。 You just need to add data-show-footer="true" to the <table> element. 您只需要向<table>元素添加data-show-footer="true"

To add values to a column you need to add the data-footer-formatter attribute to the respective <th> element and set that equal to a javascript function, which can be as simple as function myTotal(data){ return '100' } . 要将值添加到列,您需要将data-footer-formatter属性添加到相应的<th>元素,并将其设置为等于javascript函数,该函数可以与function myTotal(data){ return '100' }一样简单。

You can also style the footer by adding the data-footer-style to the <table> element and, again, setting that equal to a javascript function. 您还可以通过将data-footer-style<table>元素,然后再次将其设置为javascript函数来设置data-footer-style

See my answer here for a good, basic example: Is it possible to fix <footer> in bootstraptable? 参见我的回答,这里有一个很好的基本示例: 是否可以在bootstraptable中修复<footer>?

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

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