forked from tonytomov/jqGrid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
231ecb5
commit acb3bdc
Showing
1 changed file
with
29 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2875,29 +2875,41 @@ $.jgrid.extend({ | |
}, | ||
remapColumns : function(permutation, updateCells, keepHeader) | ||
{ | ||
// check to see there is a reason to remap | ||
var pl = permutation.length, i, remap = false; | ||
for (i = 0; i < pl; i++) { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
if (permutation[i] != i) remap = true; | ||
} | ||
|
||
if (!remap) return; | ||
|
||
function resortArray(a) { | ||
var ac; | ||
if (a.length) { | ||
ac = $.makeArray(a); | ||
} else { | ||
ac = $.extend({}, a); | ||
var ac = a.length ? $.makeArray(a) : $.extend({}, a); | ||
// replace $.each with for loop | ||
for (i = 0; i < pl; i++) { | ||
a[i] = ac[permutation[i]]; | ||
} | ||
$.each(permutation, function(i) { | ||
a[i] = ac[this]; | ||
}); | ||
} | ||
var ts = this.get(0); | ||
function resortRows(parent, clobj) { | ||
$(">tr"+(clobj||""), parent).each(function() { | ||
var row = this; | ||
var elems = $.makeArray(row.cells); | ||
$.each(permutation, function() { | ||
var e = elems[this]; | ||
if (e) { | ||
row.appendChild(e); | ||
var rows = parent.find(">tr" + (clobj || "")), | ||
This comment has been minimized.
Sorry, something went wrong.
iliadraznin
Author
Owner
|
||
rl = rows.length, | ||
ri, | ||
row, | ||
cells, | ||
cell; | ||
|
||
for (ri = 0; ri < rl; ri++) { | ||
row = rows[ri]; | ||
cells = $.makeArray(row.cells); | ||
|
||
for (i = 0; i < pl; i++) { | ||
cell = cells[permutation[i]]; | ||
if (cell) { | ||
row.appendChild(cell); | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
} | ||
resortArray(ts.p.colModel); | ||
resortArray(ts.p.colNames); | ||
|
1 comment
on commit acb3bdc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Performance improvements for remapColumns
In some cases, such with columnChooser, remapColumns may be called without actually having a different order for the columns, this check should improve performance significantly in such cases, without impacting much the rest.