[minor] Fix getCell, reset sort action, set minWidth only once

This commit is contained in:
Faris Ansari 2017-10-01 12:41:41 +05:30
parent fa6a582a45
commit 0db68e46d5
3 changed files with 23 additions and 7 deletions

View File

@ -352,14 +352,17 @@ var ReGrid = function () {
margin: 0
});
this.minWidthMap = [];
this.minWidthMap = (0, _utils.getDefault)(this.minWidthMap, []);
// set the width for each column
this.header.find('.data-table-col').each(function () {
var col = (0, _jQuery2.default)(this);
var width = col.find('.content').width();
var colIndex = col.attr('data-col-index');
self.minWidthMap[colIndex] = width;
if (!self.minWidthMap[colIndex]) {
// only set this once
self.minWidthMap[colIndex] = width;
}
self.setColumnWidth(colIndex, width);
});
@ -501,6 +504,10 @@ var ReGrid = function () {
var sortAction = (0, _utils.getDefault)($cell.attr('data-sort-action'), 'none');
var colIndex = $cell.attr('data-col-index');
// reset sort indicator
self.header.find('.sort-indicator').text('');
self.header.find('.data-table-col').attr('data-sort-action', 'none');
if (sortAction === 'none') {
$cell.attr('data-sort-action', 'asc');
$cell.find('.sort-indicator').text('▲');
@ -656,7 +663,9 @@ var ReGrid = function () {
value: function getCell(rowIndex, colIndex) {
rowIndex = +rowIndex;
colIndex = +colIndex;
return this.data.rows[rowIndex][colIndex];
return this.data.rows.find(function (row) {
return row[0].rowIndex === rowIndex;
})[colIndex];
}
}, {
key: 'getColumnHeaderElement',

File diff suppressed because one or more lines are too long

View File

@ -235,14 +235,17 @@ export default class ReGrid {
margin: 0
});
this.minWidthMap = [];
this.minWidthMap = getDefault(this.minWidthMap, []);
// set the width for each column
this.header.find('.data-table-col').each(function () {
const col = $(this);
const width = col.find('.content').width();
const colIndex = col.attr('data-col-index');
self.minWidthMap[colIndex] = width;
if (!self.minWidthMap[colIndex]) {
// only set this once
self.minWidthMap[colIndex] = width;
}
self.setColumnWidth(colIndex, width);
});
@ -375,6 +378,10 @@ export default class ReGrid {
const sortAction = getDefault($cell.attr('data-sort-action'), 'none');
const colIndex = $cell.attr('data-col-index');
// reset sort indicator
self.header.find('.sort-indicator').text('');
self.header.find('.data-table-col').attr('data-sort-action', 'none');
if (sortAction === 'none') {
$cell.attr('data-sort-action', 'asc');
$cell.find('.sort-indicator').text('▲');
@ -515,7 +522,7 @@ export default class ReGrid {
getCell(rowIndex, colIndex) {
rowIndex = +rowIndex;
colIndex = +colIndex;
return this.data.rows[rowIndex][colIndex];
return this.data.rows.find(row => row[0].rowIndex === rowIndex)[colIndex];
}
getColumnHeaderElement(colIndex) {