Twitter引导表reOrder列未维持秩序



我有一个Twitter引导表扩展,可以对列进行重新排序,这很有效,除非我移动列时它会回到原来的顺序。

甚至他们网站上的例子也做了同样的事情。我是不是错过了什么?

var $table = $('#table-javascript').bootstrapTable({
method: 'POST',
url: 'report.php,
cache: false,
pagination: true,
pageSize: 20,
pageList: [20, 35, 60, 110],
sortable: true,
search: true,
minimumCountColumns: 2,
reorderableColumns: true,
});

我也遇到了同样的错误,经过一番搜索,我在Bootstrap表存储库中发现了这个悬而未决的问题:https://github.com/wenzhixin/bootstrap-table/issues/3427

这个家伙找到了一种方法来修复它,方法是更改引导表reorder columns.js中的一些代码行。

~160行中,您有以下代码片段:

for (var i = 0; i < this.length; i++) {
columnIndex = that.fieldsColumnsIndex[ths[i]];
if (columnIndex !== -1) {
that.columns[columnIndex].fieldIndex = i;
columns.push(that.columns[columnIndex]);
that.columns.splice(columnIndex, 1);
}
}
that.columns = that.columns.concat(columns);

只需将其更改为:

for (var i = 0; i < ths.length; i++ ) {
columnIndex = that.fieldsColumnsIndex[ths[i]];
that.columns[columnIndex].fieldIndex = i;
that.fieldsColumnsIndex[ths[i]] = i
columns.push(that.columns[columnIndex]);
}
that.columns = columns;

就这样!现在应该可以工作了:(

此解决方案的所有积分都将转到https://github.com/Guxingzhe

最新更新