Skip to content

Commit cdd438b

Browse files
committed
fix #570: flex column config of put_datatable() don't work
1 parent d9712f1 commit cdd438b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

webiojs/src/models/datatable.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@ const gridDefaultColDef = {
232232

233233
sortable: true,
234234
filter: true,
235-
// flex: 1,
236-
// minWidth: 90,
235+
237236
resizable: true,
238237

239238
// allow every column to be aggregated
@@ -280,6 +279,12 @@ export let Datatable = {
280279
// @ts-ignore
281280
window[`ag_grid_${spec.instance_id}_promise`] = gridPromise;
282281

282+
let column_flex_enabled = (
283+
(spec.field_args && Object.keys(spec.field_args).some((k: any) => spec.field_args[k].flex))
284+
|| (spec.path_args && spec.path_args.some((k: any) => k[1].flex))
285+
|| (spec.grid_args.defaultColDef || {}).flex
286+
);
287+
283288
const gridOptions: any = {
284289
...gridDefaultOptions,
285290
...spec.grid_args,
@@ -331,6 +336,8 @@ export let Datatable = {
331336
});
332337
}
333338
on_grid_show.then(() => {
339+
if (column_flex_enabled)
340+
return;
334341
gridOptions.columnApi.autoSizeAllColumns();
335342
let content_width = 0;
336343
gridOptions.columnApi.getColumns().forEach((column: any) => {

0 commit comments

Comments
 (0)