From cc4081f9a0afff76c0f3237009c7c6e759cc1ce0 Mon Sep 17 00:00:00 2001 From: lxsang Date: Thu, 24 Sep 2020 18:41:30 +0200 Subject: [PATCH] allow enable/disable grid resize feature --- src/core/tags/FileViewTag.ts | 1 + src/core/tags/GridViewTag.ts | 49 ++++++++++++++++++++++++------------ src/core/tags/ResizerTag.ts | 3 ++- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/core/tags/FileViewTag.ts b/src/core/tags/FileViewTag.ts index 5d52248..ebb92d2 100644 --- a/src/core/tags/FileViewTag.ts +++ b/src/core/tags/FileViewTag.ts @@ -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; diff --git a/src/core/tags/GridViewTag.ts b/src/core/tags/GridViewTag.ts index 4252590..2549994 100644 --- a/src/core/tags/GridViewTag.ts +++ b/src/core/tags/GridViewTag.ts @@ -443,6 +443,7 @@ namespace OS { this._selectedRows = []; this._selectedRow = undefined; this._rows = []; + this.resizable = false; this._oncellselect = this._onrowselect = this._oncelldbclick = ( e: TagEventType ): void => {}; @@ -539,22 +540,24 @@ namespace OS { element.data = item; item.domel = element; i++; - if (i != v.length) { - const rz = $(``).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 = $(``).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 "; } } diff --git a/src/core/tags/ResizerTag.ts b/src/core/tags/ResizerTag.ts index dd4163d..cc4975d 100644 --- a/src/core/tags/ResizerTag.ts +++ b/src/core/tags/ResizerTag.ts @@ -139,7 +139,8 @@ namespace OS { * * Getter: * - get the resize event callback - * @memberof GridViewTag + * + * @memberof ResizerTag */ set onelresize(v: TagEventCallback) { this._onresize = v;