I have two slickgrids on my page, side by side.
slickgrid1 slickgrid2
|ID Col1 Col2 | |ID Col3 Col4 |
|1 | |1 |
|2 | |2 |
|3 | |3 |
|4 | |4 |
|5 | |5 |
I use two instead of one, to let the user separate them, position them freely.
The sorting is only enabled on slickgrid1's columns, and slickgrid2's ID column.
I would like to sort both of the slickgrids at the same time, when I click a header in slickgrid1. (basically let the two slickgrids act like they are one)
Is there a way to chain the sort event so the second grids rows are paired by the ID column to the first slickgrids ID column?
Here is the onsort event that I use for slickgrid1:
slickgrid1.onSort.subscribe(function (e, args) {
var cols = args.sortCols;
resourcedata.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 = dataRow1[field], value2 = dataRow2[field];
var result = (value1 == value2 ? 0 : (value1 > value2 ? 1 : -1)) * sign;
if (result != 0) {
return result;
}
}
return 0;
});
slickgrid1.invalidate();
slickgrid1.render();
});