Skip to content

Commit 412f77c

Browse files
author
syshex
committed
adding sortable for individual columns - available from 1.1.12
1 parent ddf9cc4 commit 412f77c

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Or add the js script to your html (download from [releases](https://github.com/j
8989
title:"country",
9090
visible: true,
9191
editable: true,
92+
sortable: false
9293
}
9394
],
9495
values: [
@@ -265,6 +266,7 @@ The `columns` array takes object of type:
265266
columnstyle: String // Optional: styles to be applied to the Column Header
266267
cellstyle: String // Optional: styles to be applied to the Cells of this column
267268
renderfunction: Function // Optional: Function that receives as input the column name and entry, and returns an HTML String for drawing cell
269+
sortable: Boolean // Optional, by default it is true! Used to set particular columns as not sortable, in case the table is sortable itself. - From 1.1.12
268270
}
269271
```
270272

dist/vue-bootstrap-table.js

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-bootstrap-table.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-bootstrap-table.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/VueBootstrapTable.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<table class="table table-bordered table-hover table-condensed table-striped vue-table">
3838
<thead>
3939
<tr>
40-
<th v-for="column in displayColsVisible" @click="sortBy($event, column.name)"
40+
<th v-for="column in displayColsVisible" @click="sortBy($event, column.name, column.sortable)"
4141
track-by="column"
4242
:class="getClasses(column)">
4343
{{ column.title }}
@@ -687,6 +687,10 @@
687687
obj.cellstyle = column.cellstyle;
688688
else
689689
obj.cellstyle = "";
690+
if ( typeof column.sortable !== "undefined")
691+
obj.sortable = column.sortable;
692+
else
693+
obj.sortable = true;
690694
691695
return obj;
692696
},
@@ -699,7 +703,9 @@
699703
this.sortOrders = sortOrders;
700704
701705
},
702-
sortBy: function (event, key) {
706+
sortBy: function (event, key, enabled) {
707+
if (!enabled)
708+
return;
703709
if (this.sortable) {
704710
var self = this;
705711
@@ -729,7 +735,7 @@
729735
getClasses: function (column) {
730736
var classes = [column.columnstyle];
731737
var key = column.name;
732-
if (this.sortable) {
738+
if (this.sortable && column.sortable) {
733739
classes.push("arrow");
734740
/*if (this.sortKey === key) {
735741
classes.push("active");

0 commit comments

Comments
 (0)