allow enable/disable grid resize feature

This commit is contained in:
lxsang 2020-09-24 18:41:30 +02:00
parent 45d425d5db
commit cc4081f9a0
3 changed files with 36 additions and 17 deletions

View File

@ -582,6 +582,7 @@ namespace OS {
};
const grid = this.refs.gridview as GridViewTag;
const list = this.refs.listview as ListViewTag;
grid.resizable = true;
grid.header = this._header;
tree.dragndrop = true;
list.dragndrop = true;

View File

@ -443,6 +443,7 @@ namespace OS {
this._selectedRows = [];
this._selectedRow = undefined;
this._rows = [];
this.resizable = false;
this._oncellselect = this._onrowselect = this._oncelldbclick = (
e: TagEventType<CellEventData>
): void => {};
@ -539,22 +540,24 @@ namespace OS {
element.data = item;
item.domel = element;
i++;
if (i != v.length) {
const rz = $(`<afx-resizer>`).appendTo(
this.refs.header
)[0] as ResizerTag;
$(rz).css("width", "3px");
let next_item = undefined;
if (i < v.length) {
next_item = v[i];
}
rz.onelresize = (e) => {
item.width = e.data.w + 3;
if (next_item) {
delete next_item.width;
if (this.resizable) {
if (i != v.length) {
const rz = $(`<afx-resizer>`).appendTo(
this.refs.header
)[0] as ResizerTag;
$(rz).css("width", "3px");
let next_item = undefined;
if (i < v.length) {
next_item = v[i];
}
};
rz.uify(this.observable);
rz.onelresize = (e) => {
item.width = e.data.w + 3;
if (next_item) {
delete next_item.width;
}
};
rz.uify(this.observable);
}
}
}
this.calibrate();
@ -623,6 +626,20 @@ namespace OS {
return this.hasattr("multiselect");
}
/**
* Set and Get the resizable attribute
*
* This allows to enable/disable column resize feature
*
* @memberof GridViewTag
*/
set resizable(v: boolean) {
this.attsw(v, "resizable");
}
get resizable(): boolean {
return this.hasattr("resizable");
}
/**
* Delete a grid rows
*
@ -867,7 +884,7 @@ namespace OS {
template += `${v}px `;
i++;
template_header += `${v}px `;
if (i < colssize.length) {
if (i < colssize.length && this.resizable) {
template_header += "3px ";
}
}

View File

@ -139,7 +139,8 @@ namespace OS {
*
* Getter:
* - get the resize event callback
* @memberof GridViewTag
*
* @memberof ResizerTag
*/
set onelresize(v: TagEventCallback<any>) {
this._onresize = v;