Skip to content

Commit 2ceba02

Browse files
committed
fix static column width on sort
1 parent 47b3f41 commit 2ceba02

File tree

4 files changed

+51
-46
lines changed

4 files changed

+51
-46
lines changed

dist/build/crud-table.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@
650650
return child_ctx;
651651
}
652652

653-
// (223:4) {#if (table_data !== undefined)}
653+
// (224:4) {#if (table_data !== undefined)}
654654
function create_if_block(ctx) {
655655
let show_if = Array.isArray(/*table_data*/ ctx[0]);
656656
let if_block_anchor;
@@ -688,7 +688,7 @@
688688
};
689689
}
690690

691-
// (225:8) {#if Array.isArray(table_data)}
691+
// (226:8) {#if Array.isArray(table_data)}
692692
function create_if_block_1(ctx) {
693693
let div2;
694694
let div1;
@@ -822,7 +822,7 @@
822822
};
823823
}
824824

825-
// (230:20) {#each table_config.columns_setting as elem, index}
825+
// (231:20) {#each table_config.columns_setting as elem, index}
826826
function create_each_block_3(ctx) {
827827
let div;
828828
let span;
@@ -899,7 +899,7 @@
899899
};
900900
}
901901

902-
// (247:24) {#if options.includes(CREATE)}
902+
// (248:24) {#if options.includes(CREATE)}
903903
function create_if_block_11(ctx) {
904904
let div;
905905
let mounted;
@@ -929,7 +929,7 @@
929929
};
930930
}
931931

932-
// (263:32) {#if (column_order.name === genericCrudTable.getKey(elem))}
932+
// (264:32) {#if (column_order.name === genericCrudTable.getKey(elem))}
933933
function create_if_block_9(ctx) {
934934
let div1;
935935
let div0;
@@ -1045,7 +1045,7 @@
10451045
};
10461046
}
10471047

1048-
// (274:44) {:else}
1048+
// (275:44) {:else}
10491049
function create_else_block_1(ctx) {
10501050
let t_value = /*table_data*/ ctx[0][/*i*/ ctx[40]][/*column_order*/ ctx[41].name] + "";
10511051
let t;
@@ -1066,7 +1066,7 @@
10661066
};
10671067
}
10681068

1069-
// (272:44) {#if column_order.type === 'html'}
1069+
// (273:44) {#if column_order.type === 'html'}
10701070
function create_if_block_10(ctx) {
10711071
let html_tag;
10721072
let raw_value = /*table_data*/ ctx[0][/*i*/ ctx[40]][/*column_order*/ ctx[41].name] + "";
@@ -1091,7 +1091,7 @@
10911091
};
10921092
}
10931093

1094-
// (284:32) {#if table_config.columns_setting.length - 1 === j && Object.entries(tableRow).length - 1 === k }
1094+
// (285:32) {#if table_config.columns_setting.length - 1 === j && Object.entries(tableRow).length - 1 === k }
10951095
function create_if_block_2(ctx) {
10961096
let div3;
10971097
let div0;
@@ -1264,7 +1264,7 @@
12641264
};
12651265
}
12661266

1267-
// (290:44) {#if options.includes(DELETE)}
1267+
// (291:44) {#if options.includes(DELETE)}
12681268
function create_if_block_8(ctx) {
12691269
let div;
12701270
let div_aria_label_value;
@@ -1307,7 +1307,7 @@
13071307
};
13081308
}
13091309

1310-
// (298:44) {#if options.includes(EDIT)}
1310+
// (299:44) {#if options.includes(EDIT)}
13111311
function create_if_block_7(ctx) {
13121312
let div;
13131313
let mounted;
@@ -1344,7 +1344,7 @@
13441344
};
13451345
}
13461346

1347-
// (305:44) {#if options.includes(DETAILS)}
1347+
// (306:44) {#if options.includes(DETAILS)}
13481348
function create_if_block_5(ctx) {
13491349
let div;
13501350
let div_title_value;
@@ -1414,7 +1414,7 @@
14141414
};
14151415
}
14161416

1417-
// (311:52) {:else}
1417+
// (312:52) {:else}
14181418
function create_else_block(ctx) {
14191419
let html_tag;
14201420
let html_anchor;
@@ -1436,7 +1436,7 @@
14361436
};
14371437
}
14381438

1439-
// (309:52) {#if table_config.details_text !== undefined}
1439+
// (310:52) {#if table_config.details_text !== undefined}
14401440
function create_if_block_6(ctx) {
14411441
let t_value = /*table_config*/ ctx[1].details_text + "";
14421442
let t;
@@ -1457,7 +1457,7 @@
14571457
};
14581458
}
14591459

1460-
// (320:44) {#if options.includes(EDIT)}
1460+
// (321:44) {#if options.includes(EDIT)}
14611461
function create_if_block_4(ctx) {
14621462
let div0;
14631463
let t;
@@ -1520,7 +1520,7 @@
15201520
};
15211521
}
15221522

1523-
// (338:44) {#if options.includes(DELETE)}
1523+
// (339:44) {#if options.includes(DELETE)}
15241524
function create_if_block_3(ctx) {
15251525
let div0;
15261526
let div0_aria_label_value;
@@ -1589,7 +1589,7 @@
15891589
};
15901590
}
15911591

1592-
// (261:28) {#each Object.entries(tableRow) as elem, k}
1592+
// (262:28) {#each Object.entries(tableRow) as elem, k}
15931593
function create_each_block_2(ctx) {
15941594
let show_if_1 = /*column_order*/ ctx[41].name === /*genericCrudTable*/ ctx[4].getKey(/*elem*/ ctx[44]);
15951595
let t;
@@ -1651,7 +1651,7 @@
16511651
};
16521652
}
16531653

1654-
// (260:24) {#each table_config.columns_setting as column_order, j}
1654+
// (261:24) {#each table_config.columns_setting as column_order, j}
16551655
function create_each_block_1(ctx) {
16561656
let each_1_anchor;
16571657
let each_value_2 = Object.entries(/*tableRow*/ ctx[38]);
@@ -1707,7 +1707,7 @@
17071707
};
17081708
}
17091709

1710-
// (257:16) {#each table_data as tableRow, i (tableRow)}
1710+
// (258:16) {#each table_data as tableRow, i (tableRow)}
17111711
function create_each_block(key_1, ctx) {
17121712
let div;
17131713
let t;
@@ -2009,9 +2009,11 @@
20092009
}
20102010

20112011
function setWidth(elem, i) {
2012-
const width = genericCrudTable.getShowFieldWidth(elem.name); // incl.px
2013-
columnsWidth[i] = width;
2014-
return "width:" + width + ";";
2012+
if (columnsWidth[i] === undefined) {
2013+
columnsWidth[i] = genericCrudTable.getShowFieldWidth(elem.name); // incl.px;
2014+
}
2015+
2016+
return "width:" + columnsWidth[i] + ";";
20152017
}
20162018

20172019
const click_handler = (elem, e) => handleSort(elem.name, e);

dist/build/crud-table.mjs

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ function get_each_context_3(ctx, list, i) {
644644
return child_ctx;
645645
}
646646

647-
// (223:4) {#if (table_data !== undefined)}
647+
// (224:4) {#if (table_data !== undefined)}
648648
function create_if_block(ctx) {
649649
let show_if = Array.isArray(/*table_data*/ ctx[0]);
650650
let if_block_anchor;
@@ -682,7 +682,7 @@ function create_if_block(ctx) {
682682
};
683683
}
684684

685-
// (225:8) {#if Array.isArray(table_data)}
685+
// (226:8) {#if Array.isArray(table_data)}
686686
function create_if_block_1(ctx) {
687687
let div2;
688688
let div1;
@@ -816,7 +816,7 @@ function create_if_block_1(ctx) {
816816
};
817817
}
818818

819-
// (230:20) {#each table_config.columns_setting as elem, index}
819+
// (231:20) {#each table_config.columns_setting as elem, index}
820820
function create_each_block_3(ctx) {
821821
let div;
822822
let span;
@@ -893,7 +893,7 @@ function create_each_block_3(ctx) {
893893
};
894894
}
895895

896-
// (247:24) {#if options.includes(CREATE)}
896+
// (248:24) {#if options.includes(CREATE)}
897897
function create_if_block_11(ctx) {
898898
let div;
899899
let mounted;
@@ -923,7 +923,7 @@ function create_if_block_11(ctx) {
923923
};
924924
}
925925

926-
// (263:32) {#if (column_order.name === genericCrudTable.getKey(elem))}
926+
// (264:32) {#if (column_order.name === genericCrudTable.getKey(elem))}
927927
function create_if_block_9(ctx) {
928928
let div1;
929929
let div0;
@@ -1039,7 +1039,7 @@ function create_if_block_9(ctx) {
10391039
};
10401040
}
10411041

1042-
// (274:44) {:else}
1042+
// (275:44) {:else}
10431043
function create_else_block_1(ctx) {
10441044
let t_value = /*table_data*/ ctx[0][/*i*/ ctx[40]][/*column_order*/ ctx[41].name] + "";
10451045
let t;
@@ -1060,7 +1060,7 @@ function create_else_block_1(ctx) {
10601060
};
10611061
}
10621062

1063-
// (272:44) {#if column_order.type === 'html'}
1063+
// (273:44) {#if column_order.type === 'html'}
10641064
function create_if_block_10(ctx) {
10651065
let html_tag;
10661066
let raw_value = /*table_data*/ ctx[0][/*i*/ ctx[40]][/*column_order*/ ctx[41].name] + "";
@@ -1085,7 +1085,7 @@ function create_if_block_10(ctx) {
10851085
};
10861086
}
10871087

1088-
// (284:32) {#if table_config.columns_setting.length - 1 === j && Object.entries(tableRow).length - 1 === k }
1088+
// (285:32) {#if table_config.columns_setting.length - 1 === j && Object.entries(tableRow).length - 1 === k }
10891089
function create_if_block_2(ctx) {
10901090
let div3;
10911091
let div0;
@@ -1258,7 +1258,7 @@ function create_if_block_2(ctx) {
12581258
};
12591259
}
12601260

1261-
// (290:44) {#if options.includes(DELETE)}
1261+
// (291:44) {#if options.includes(DELETE)}
12621262
function create_if_block_8(ctx) {
12631263
let div;
12641264
let div_aria_label_value;
@@ -1301,7 +1301,7 @@ function create_if_block_8(ctx) {
13011301
};
13021302
}
13031303

1304-
// (298:44) {#if options.includes(EDIT)}
1304+
// (299:44) {#if options.includes(EDIT)}
13051305
function create_if_block_7(ctx) {
13061306
let div;
13071307
let mounted;
@@ -1338,7 +1338,7 @@ function create_if_block_7(ctx) {
13381338
};
13391339
}
13401340

1341-
// (305:44) {#if options.includes(DETAILS)}
1341+
// (306:44) {#if options.includes(DETAILS)}
13421342
function create_if_block_5(ctx) {
13431343
let div;
13441344
let div_title_value;
@@ -1408,7 +1408,7 @@ function create_if_block_5(ctx) {
14081408
};
14091409
}
14101410

1411-
// (311:52) {:else}
1411+
// (312:52) {:else}
14121412
function create_else_block(ctx) {
14131413
let html_tag;
14141414
let html_anchor;
@@ -1430,7 +1430,7 @@ function create_else_block(ctx) {
14301430
};
14311431
}
14321432

1433-
// (309:52) {#if table_config.details_text !== undefined}
1433+
// (310:52) {#if table_config.details_text !== undefined}
14341434
function create_if_block_6(ctx) {
14351435
let t_value = /*table_config*/ ctx[1].details_text + "";
14361436
let t;
@@ -1451,7 +1451,7 @@ function create_if_block_6(ctx) {
14511451
};
14521452
}
14531453

1454-
// (320:44) {#if options.includes(EDIT)}
1454+
// (321:44) {#if options.includes(EDIT)}
14551455
function create_if_block_4(ctx) {
14561456
let div0;
14571457
let t;
@@ -1514,7 +1514,7 @@ function create_if_block_4(ctx) {
15141514
};
15151515
}
15161516

1517-
// (338:44) {#if options.includes(DELETE)}
1517+
// (339:44) {#if options.includes(DELETE)}
15181518
function create_if_block_3(ctx) {
15191519
let div0;
15201520
let div0_aria_label_value;
@@ -1583,7 +1583,7 @@ function create_if_block_3(ctx) {
15831583
};
15841584
}
15851585

1586-
// (261:28) {#each Object.entries(tableRow) as elem, k}
1586+
// (262:28) {#each Object.entries(tableRow) as elem, k}
15871587
function create_each_block_2(ctx) {
15881588
let show_if_1 = /*column_order*/ ctx[41].name === /*genericCrudTable*/ ctx[4].getKey(/*elem*/ ctx[44]);
15891589
let t;
@@ -1645,7 +1645,7 @@ function create_each_block_2(ctx) {
16451645
};
16461646
}
16471647

1648-
// (260:24) {#each table_config.columns_setting as column_order, j}
1648+
// (261:24) {#each table_config.columns_setting as column_order, j}
16491649
function create_each_block_1(ctx) {
16501650
let each_1_anchor;
16511651
let each_value_2 = Object.entries(/*tableRow*/ ctx[38]);
@@ -1701,7 +1701,7 @@ function create_each_block_1(ctx) {
17011701
};
17021702
}
17031703

1704-
// (257:16) {#each table_data as tableRow, i (tableRow)}
1704+
// (258:16) {#each table_data as tableRow, i (tableRow)}
17051705
function create_each_block(key_1, ctx) {
17061706
let div;
17071707
let t;
@@ -2003,9 +2003,11 @@ function instance($$self, $$props, $$invalidate) {
20032003
}
20042004

20052005
function setWidth(elem, i) {
2006-
const width = genericCrudTable.getShowFieldWidth(elem.name); // incl.px
2007-
columnsWidth[i] = width;
2008-
return "width:" + width + ";";
2006+
if (columnsWidth[i] === undefined) {
2007+
columnsWidth[i] = genericCrudTable.getShowFieldWidth(elem.name); // incl.px;
2008+
}
2009+
2010+
return "width:" + columnsWidth[i] + ";";
20092011
}
20102012

20112013
const click_handler = (elem, e) => handleSort(elem.name, e);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svelte-generic-crud-table",
3-
"version": "1.5.73",
3+
"version": "1.5.74",
44
"description": "<crud-table> renders object-arrays with options-panel and inline edit per row. Dispatches events for ongoing data handling. As self-containing webcomponent or for Svelte in 60KB",
55
"main": "dist/build/crud-table.js",
66
"module": "dist/build/crud-table.mjs",

src/SvelteGenericCrudTable.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,10 @@
176176
}
177177
178178
function setWidth(elem, i) {
179-
const width = genericCrudTable.getShowFieldWidth(elem.name); // incl.px
180-
columnsWidth[i] = width;
181-
return "width:" + width + ";"
179+
if (columnsWidth[i] === undefined) {
180+
columnsWidth[i] = genericCrudTable.getShowFieldWidth(elem.name); // incl.px;
181+
}
182+
return "width:" + columnsWidth[i] + ";"
182183
}
183184
184185
function tooltip(event, x, y, text, type) {

0 commit comments

Comments
 (0)