Limit column resize to minWidth
This commit is contained in:
parent
86d6b19277
commit
150db0fef7
@ -360,12 +360,14 @@ var ReGrid = function () {
|
|||||||
margin: 0
|
margin: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.minWidthMap = [];
|
||||||
// set the width for each column
|
// set the width for each column
|
||||||
this.header.find('.data-table-col').each(function () {
|
this.header.find('.data-table-col').each(function () {
|
||||||
var col = (0, _jQuery2.default)(this);
|
var col = (0, _jQuery2.default)(this);
|
||||||
var width = col.find('.content').width();
|
var width = col.find('.content').width();
|
||||||
var colIndex = col.attr('data-col-index');
|
var colIndex = col.attr('data-col-index');
|
||||||
|
|
||||||
|
self.minWidthMap[colIndex] = width;
|
||||||
self.setColumnWidth(colIndex, width);
|
self.setColumnWidth(colIndex, width);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -452,6 +454,11 @@ var ReGrid = function () {
|
|||||||
var finalWidth = startWidth + (e.pageX - startX);
|
var finalWidth = startWidth + (e.pageX - startX);
|
||||||
var colIndex = $currCell.attr('data-col-index');
|
var colIndex = $currCell.attr('data-col-index');
|
||||||
|
|
||||||
|
if (self.getColumnMinWidth(colIndex) > finalWidth) {
|
||||||
|
// don't resize past minWidth
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
self.setColumnWidth(colIndex, finalWidth);
|
self.setColumnWidth(colIndex, finalWidth);
|
||||||
self.setBodyWidth();
|
self.setBodyWidth();
|
||||||
// self.setColumnHeaderWidth($currCell, finalWidth);
|
// self.setColumnHeaderWidth($currCell, finalWidth);
|
||||||
@ -638,6 +645,12 @@ var ReGrid = function () {
|
|||||||
if (colIndex < 0) return null;
|
if (colIndex < 0) return null;
|
||||||
return this.wrapper.find('.data-table-col[data-is-header][data-col-index="' + colIndex + '"]');
|
return this.wrapper.find('.data-table-col[data-is-header][data-col-index="' + colIndex + '"]');
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
key: 'getColumnMinWidth',
|
||||||
|
value: function getColumnMinWidth(colIndex) {
|
||||||
|
colIndex = +colIndex;
|
||||||
|
return this.minWidthMap && this.minWidthMap[colIndex];
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'log',
|
key: 'log',
|
||||||
value: function log() {
|
value: function log() {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -243,12 +243,14 @@ export default class ReGrid {
|
|||||||
margin: 0
|
margin: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.minWidthMap = [];
|
||||||
// set the width for each column
|
// set the width for each column
|
||||||
this.header.find('.data-table-col').each(function () {
|
this.header.find('.data-table-col').each(function () {
|
||||||
const col = $(this);
|
const col = $(this);
|
||||||
const width = col.find('.content').width();
|
const width = col.find('.content').width();
|
||||||
const colIndex = col.attr('data-col-index');
|
const colIndex = col.attr('data-col-index');
|
||||||
|
|
||||||
|
self.minWidthMap[colIndex] = width;
|
||||||
self.setColumnWidth(colIndex, width);
|
self.setColumnWidth(colIndex, width);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -335,6 +337,11 @@ export default class ReGrid {
|
|||||||
const finalWidth = startWidth + (e.pageX - startX);
|
const finalWidth = startWidth + (e.pageX - startX);
|
||||||
const colIndex = $currCell.attr('data-col-index');
|
const colIndex = $currCell.attr('data-col-index');
|
||||||
|
|
||||||
|
if (self.getColumnMinWidth(colIndex) > finalWidth) {
|
||||||
|
// don't resize past minWidth
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
self.setColumnWidth(colIndex, finalWidth);
|
self.setColumnWidth(colIndex, finalWidth);
|
||||||
self.setBodyWidth();
|
self.setBodyWidth();
|
||||||
// self.setColumnHeaderWidth($currCell, finalWidth);
|
// self.setColumnHeaderWidth($currCell, finalWidth);
|
||||||
@ -515,6 +522,11 @@ export default class ReGrid {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getColumnMinWidth(colIndex) {
|
||||||
|
colIndex = +colIndex;
|
||||||
|
return this.minWidthMap && this.minWidthMap[colIndex];
|
||||||
|
}
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
if (this.enableLogs) {
|
if (this.enableLogs) {
|
||||||
console.log.apply(console, arguments);
|
console.log.apply(console, arguments);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user