Skip to content

Commit

Permalink
Fixed Bug:1382372
Browse files Browse the repository at this point in the history
BUG: On chrome, the grid rows when rendered for the first time were sorted in a random way where first row was getting swapped with another row placed halfway.
ISSUE: This was introduced with defaultSort option added which used to perform sort unnecessarily and changed the behaviour of rows on chrome
FIX: Added a check to perform default sort of grid only when the length of defaultSortCols > 0

Change-Id: I1c71dd8ce63a481c796abf7645ee5a0b783ca637
  • Loading branch information
Sagar Gala committed Dec 11, 2014
1 parent 1aae8cc commit be9ae86
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions webroot/js/slickgrid-utils.js
Expand Up @@ -775,19 +775,21 @@ function getDefaultGridConfig() {
};

function performSort(cols) {
dataView.sort(function (dataRow1, dataRow2) {
for (var i = 0, l = cols.length; i < l; i++) {
var field = cols[i].sortCol.field;
var sign = cols[i].sortAsc ? 1 : -1;
var value1 = (contrail.checkIfExist(cols[i].sortCol.sortable.sortBy) && cols[i].sortCol.sortable.sortBy == 'formattedValue') ? cols[i].sortCol.formatter('','','','',dataRow1) : dataRow1[field],
value2 = (contrail.checkIfExist(cols[i].sortCol.sortable.sortBy) && cols[i].sortCol.sortable.sortBy == 'formattedValue') ? cols[i].sortCol.formatter('','','','',dataRow2) : dataRow2[field];
var result = (value1 == value2 ? 0 : (value1 > value2 ? 1 : -1)) * sign;
if (result != 0) {
return result;
if (cols.length > 0) {
dataView.sort(function (dataRow1, dataRow2) {
for (var i = 0, l = cols.length; i < l; i++) {
var field = cols[i].sortCol.field;
var sign = cols[i].sortAsc ? 1 : -1;
var value1 = (contrail.checkIfExist(cols[i].sortCol.sortable.sortBy) && cols[i].sortCol.sortable.sortBy == 'formattedValue') ? cols[i].sortCol.formatter('', '', '', '', dataRow1) : dataRow1[field],
value2 = (contrail.checkIfExist(cols[i].sortCol.sortable.sortBy) && cols[i].sortCol.sortable.sortBy == 'formattedValue') ? cols[i].sortCol.formatter('', '', '', '', dataRow2) : dataRow2[field];
var result = (value1 == value2 ? 0 : (value1 > value2 ? 1 : -1)) * sign;
if (result != 0) {
return result;
}
}
}
return 0;
});
return 0;
});
}
};

function initSearchBox() {
Expand Down

0 comments on commit be9ae86

Please sign in to comment.