I have a table make with Vue-good-table in Vue.js.
I need to find a way for do it resizable. Something like this. https://codepen.io/validide/pen/aOKLNo
Unfortunately, Vue-good-table do not have this option, far as I know. https://github.com/xaksis/vue-good-table/issues/226
I tested with JQuery, but I do not want mix Jquery and Vue, and I do not know if a library in Jquery, it will work with this component. I tested but I did not find any.
There is another way in Javascript/css or Vue for do it?
<vue-good-table
@on-select-all="'selectAll'"
:columns="columns"
:rows="rows"
:select-options="{ enabled: true }"
@on-selected-rows-change="selectionChanged"
:sort-options="{
enabled: true
}"></<vue-good-table>
Thanks.
add mounted
method to your component like this:
mounted: function () {
var thElm;
var startOffset;
Array.prototype.forEach.call(
document.querySelectorAll("table th"),
function (th) {
th.style.position = 'relative';
var grip = document.createElement('div');
grip.innerHTML = " ";
grip.style.top = 0;
grip.style.right = 0;
grip.style.bottom = 0;
grip.style.width = '5px';
grip.style.position = 'absolute';
grip.style.cursor = 'col-resize';
grip.addEventListener('mousedown', function (e) {
thElm = th;
startOffset = th.offsetWidth - e.pageX;
});
th.appendChild(grip);
});
document.addEventListener('mousemove', function (e) {
if (thElm) {
thElm.style.width = startOffset + e.pageX + 'px';
}
});
document.addEventListener('mouseup', function () {
thElm = undefined;
});
}