Skip to content

Commit 70efbda

Browse files
committed
Add row data to sorter function
1 parent 3e3c4f7 commit 70efbda

4 files changed

Lines changed: 21 additions & 11 deletions

File tree

docs/_i18n/en/documentation/column-options.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ function formatter(value, row, index, field) {
212212
<td>
213213
The custom field sort function that used to do local sorting, take two parameters: <br>
214214
a: the first field value.<br>
215-
b: the second field value.
215+
b: the second field value.<br>
216+
rowA: the first row.<br>
217+
rowB: the second row.
216218
</td>
217219
</tr>
218220
<tr>

docs/_i18n/es/documentation/column-options.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,10 @@ Las propiedades de la columna están definidas en `jQuery.fn.bootstrapTable.colu
197197
<td>
198198
La función sort es usada para hacer el ordenamiendo customizable, toma dos parámetros: <br>
199199
a: el primer valor del campo.<br>
200-
b: el segundo valor del campo.</td>
200+
b: el segundo valor del campo.<br>
201+
rowA: la primera fila.<br>
202+
rowB: la segunda fila.
203+
</td>
201204
</tr>
202205
<tr>
203206
<td>sortName</td>

docs/_i18n/zh-cn/documentation/column-options.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ The column options is defined in `jQuery.fn.bootstrapTable.columnDefaults`.
199199
<td>
200200
The custom field sort function that used to do local sorting, take two parameters: <br>
201201
a: the first field value.<br>
202-
b: the second field value.
202+
b: the second field value.<br>
203+
rowA: the first row.<br>
204+
rowB: the second row.
203205
</td>
204206
</tr>
205207
<tr>

src/bootstrap-table.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,9 @@
604604
if (this.options.locale) {
605605
var parts = this.options.locale.split(/-|_/);
606606
parts[0].toLowerCase();
607-
if (parts[1]) parts[1].toUpperCase();
607+
if (parts[1]) {
608+
parts[1].toUpperCase();
609+
}
608610
if ($.fn.bootstrapTable.locales[this.options.locale]) {
609611
// locale as requested
610612
$.extend(this.options, $.fn.bootstrapTable.locales[this.options.locale]);
@@ -727,9 +729,11 @@
727729
var $this = $(this),
728730
cspan = +$this.attr('colspan') || 1,
729731
rspan = +$this.attr('rowspan') || 1,
730-
tx, ty;
732+
tx,
733+
ty;
731734

732-
for (; m[y] && m[y][x]; x++); //skip already occupied cells in current row
735+
// skip already occupied cells in current row
736+
for (; m[y] && m[y][x]; x++);
733737

734738
for (tx = x; tx < x + cspan; tx++) { //mark matrix elements occupied by current cell with true
735739
for (ty = y; ty < y + rspan; ty++) {
@@ -976,7 +980,7 @@
976980
}
977981
var aa = getItemField(a, name, that.options.escape),
978982
bb = getItemField(b, name, that.options.escape),
979-
value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb]);
983+
value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb, a, b]);
980984

981985
if (value !== undefined) {
982986
if (that.options.sortStable && value === 0) {
@@ -2603,9 +2607,8 @@
26032607
return;
26042608
}
26052609

2606-
this.columns[this.fieldsColumnsIndex[params.field]].title = this.options.escape
2607-
? escapeHTML(params.title)
2608-
: params.title;
2610+
this.columns[this.fieldsColumnsIndex[params.field]].title =
2611+
this.options.escape ? escapeHTML(params.title) : params.title;
26092612

26102613
if (this.columns[this.fieldsColumnsIndex[params.field]].visible) {
26112614
var header = this.options.height !== undefined ? this.$tableHeader : this.$header;
@@ -2755,7 +2758,7 @@
27552758
if (rowId === -1) {
27562759
return;
27572760
}
2758-
that.data[rowId][params.field] = params.value
2761+
that.data[rowId][params.field] = params.value;
27592762
});
27602763

27612764
if (params.reinit === false) {

0 commit comments

Comments
 (0)