Skip to content

Commit 968e643

Browse files
authored
fix: updating columns should include internal plugin columns (#2607)
* fix: updating columns should include internal plugin columns
1 parent 7871d08 commit 968e643

34 files changed

Lines changed: 411 additions & 820 deletions

File tree

demos/aurelia/src/examples/slickgrid/example03.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -598,15 +598,6 @@ export class Example03 {
598598
// you can dynamically add your column to your column definitions
599599
// and then use the spread operator [...cols] OR slice to force Aurelia to review the changes
600600
this.columns.push(newCol);
601-
602-
// NOTE if you use an Extensions (Checkbox Selector, Row Detail, ...) that modifies the column definitions in any way
603-
// you MUST use "getAllColumnDefinitions()" from the GridService, using this will be ALL columns including the 1st column that is created internally
604-
// for example if you use the Checkbox Selector (row selection), you MUST use the code below
605-
/*
606-
const allColumns = this.aureliaGrid.gridService.getAllColumnDefinitions();
607-
allColumns.push(newCol);
608-
this.columns = [...allColumns]; // (or use slice) reassign to column definitions for Aurelia to do dirty checking
609-
*/
610601
}
611602

612603
dynamicallyRemoveLastColumn() {

demos/aurelia/src/examples/slickgrid/example12.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,16 +270,9 @@ export class Example12 {
270270
params: { useFormatterOuputToFilter: true },
271271
};
272272
this.columns.push(newCol);
273-
this.columns = this.columns.slice(); // or use spread operator [...cols]
274273

275-
// NOTE if you use an Extensions (Checkbox Selector, Row Detail, ...) that modifies the column definitions in any way
276-
// you MUST use "getAllColumnDefinitions()" from the GridService, using this will be ALL columns including the 1st column that is created internally
277-
// for example if you use the Checkbox Selector (row selection), you MUST use the code below
278-
/*
279-
const allColumns = this.aureliaGrid.gridService.getAllColumnDefinitions();
280-
allColumns.push(newCol);
281-
this.columns = [...allColumns]; // (or use slice) reassign to column definitions for Aurelia to do dirty checking
282-
*/
274+
// use slice spread operator [...cols] to trigger dirty checking
275+
this.columns = this.columns.slice();
283276
}
284277

285278
exportToExcel() {

demos/aurelia/src/examples/slickgrid/example16.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,9 @@ export class Example16 {
204204
},
205205
];
206206

207-
// NOTE if you use an Extensions (Checkbox Selector, Row Detail, ...) that modifies the column definitions in any way
208-
// you MUST use "getAllColumnDefinitions()" from the GridService, using this will be ALL columns including the 1st column that is created internally
209-
// for example if you use the Checkbox Selector (row selection), you MUST use the code below
207+
// use slice or spread reassign to column definitions to trigger dirty checking
210208
const allColumns = this.aureliaGrid.gridService.getAllColumnDefinitions();
211-
allColumns.unshift(newCols[0], newCols[1]);
212-
this.columns = [...allColumns]; // (or use slice) reassign to column definitions for Aurelia to do dirty checking
209+
this.columns = [...newCols, ...allColumns];
213210
}
214211
}
215212

demos/react-fluent/src/examples/slickgrid/Example02.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,8 @@ const Example02: React.FC = () => {
208208
},
209209
];
210210

211-
// NOTE if you use an Extensions (Checkbox Selector, Row Detail, ...) that modifies the column definitions in any way
212-
// you MUST use "getAllColumnDefinitions()" from the GridService, using this will be ALL columns including the 1st column that is created internally
213-
// for example if you use the Checkbox Selector (row selection), you MUST use the code below
214-
const allColumns = reactGridRef.current?.gridService.getAllColumnDefinitions() || [];
215-
allColumns.unshift(newCols[0], newCols[1]);
216-
setColumns([...allColumns]); // (or use slice) reassign to column definitions for React to do dirty checking
211+
// use slice or spread reassign to column definitions to trigger dirty checking
212+
setColumns([...newCols]);
217213
}
218214
}
219215

demos/react/src/examples/slickgrid/Example03.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -592,17 +592,8 @@ const Example3: React.FC = () => {
592592
};
593593

594594
// you can dynamically add your column to your column definitions
595-
// and then use the spread operator [...cols] OR slice to force React to review the changes
595+
// and then use the spread operator [...cols] OR slice to force dirty checking
596596
setColumns([...columns!, newCol]);
597-
598-
// NOTE if you use an Extensions (Checkbox Selector, Row Detail, ...) that modifies the column definitions in any way
599-
// you MUST use 'getAllColumnDefinitions()' from the GridService, using this will be ALL columns including the 1st column that is created internally
600-
// for example if you use the Checkbox Selector (row selection), you MUST use the code below
601-
/*
602-
const allColumns = reactGrid.gridService.getAllColumnDefinitions();
603-
allColumns.push(newCol);
604-
columns = [...allColumns]; // (or use slice) reassign to column definitions for React to do dirty checking
605-
*/
606597
}
607598

608599
function dynamicallyRemoveLastColumn() {

demos/react/src/examples/slickgrid/Example12.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ const Example12: React.FC = () => {
218218

219219
function dynamicallyAddTitleHeader() {
220220
// you can dynamically add your column to your column definitions
221-
// and then use the spread operator [...cols] OR slice to force React to review the changes
221+
// and then use the spread operator [...cols] OR slice to force dirty checking
222222
const newCol = {
223223
id: `title${duplicateTitleHeaderCount++}`,
224224
field: 'id',
@@ -231,16 +231,8 @@ const Example12: React.FC = () => {
231231
};
232232
columns.push(newCol);
233233

234-
setColumns(columns.slice()); // or use spread operator [...cols]
235-
236-
// NOTE if you use an Extensions (Checkbox Selector, Row Detail, ...) that modifies the column definitions in any way
237-
// you MUST use "getAllColumnDefinitions()" from the GridService, using this will be ALL columns including the 1st column that is created internally
238-
// for example if you use the Checkbox Selector (row selection), you MUST use the code below
239-
/*
240-
const allColumns = reactGrid.gridService.getAllColumnDefinitions();
241-
allColumns.push(newCol);
242-
columns = [...allColumns]; // (or use slice) reassign to column definitions for React to do dirty checking
243-
*/
234+
// use slice spread operator [...cols] to trigger dirty checking
235+
setColumns(columns.slice());
244236
}
245237

246238
function exportToExcel() {

demos/react/src/examples/slickgrid/Example16.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,9 @@ const Example16: React.FC = () => {
203203
},
204204
];
205205

206-
// NOTE if you use an Extensions (Checkbox Selector, Row Detail, ...) that modifies the column definitions in any way
207-
// you MUST use "getAllColumnDefinitions()" from the GridService, using this will be ALL columns including the 1st column that is created internally
208-
// for example if you use the Checkbox Selector (row selection), you MUST use the code below
206+
// use slice or spread reassign to column definitions to trigger dirty checking
209207
const allColumns = reactGridRef.current?.gridService.getAllColumnDefinitions() || [];
210-
allColumns.unshift(newCols[0], newCols[1]);
211-
setColumns([...allColumns]); // (or use slice) reassign to column definitions for React to do dirty checking
208+
setColumns([...newCols, ...allColumns]);
212209
}
213210
}
214211

demos/vanilla/src/examples/example07.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -612,27 +612,10 @@ export default class Example07 {
612612
// you can dynamically add your column to your column definitions
613613
// and then use the spread operator [...cols] OR slice to force the framework to review the changes
614614
this.sgb.columnDefinitions.push(newCol);
615-
616-
// NOTE if you use an Extensions (Checkbox Selector, Row Detail, ...) that modifies the column definitions in any way
617-
// you MUST use "getAllColumnDefinitions()" from the GridService, using this will be ALL columns including the 1st column that is created internally
618-
// for example if you use the Checkbox Selector (row selection), you MUST use the code below
619-
/*
620-
const allOriginalColumns = this.sgb.gridService.getAllColumnDefinitions();
621-
allOriginalColumns.push(newCol);
622-
this.sgb.columnDefinitions = [...allOriginalColumns]; // (or use slice) reassign to column definitions for framework to do dirty checking
623-
*/
624615
}
625616

626617
dynamicallyRemoveLastColumn() {
627618
this.sgb.columnDefinitions.pop();
628-
629-
/*
630-
const allColumns = this.slickerGridInstance.gridService.getAllColumnDefinitions();
631-
// remove your column from the full set of columns
632-
// and use slice or spread [...] to trigger a dirty change
633-
allOriginalColumns.pop();
634-
this.sgb.columnDefinitions = allOriginalColumns.slice();
635-
*/
636619
}
637620

638621
hideFinishColumnDynamically() {

demos/vue/src/components/Example03.vue

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -586,14 +586,6 @@ function dynamicallyAddTitleHeader() {
586586
587587
// you can dynamically add your column to your column definitions
588588
columns.value.push(newCol);
589-
590-
// NOTE if you use an Extensions (Checkbox Selector, Row Detail, ...) that modifies the column definitions in any way
591-
// you MUST use "getAllColumnDefinitions()" from the GridService, using this will be ALL columns including the 1st column that is created internally
592-
// for example if you use the Checkbox Selector (row selection), you MUST use the code below
593-
/*
594-
const allColumns = vueGrid.gridService.getAllColumnDefinitions();
595-
allColumns.push(newCol);
596-
*/
597589
}
598590
599591
function dynamicallyRemoveLastColumn() {

demos/vue/src/components/Example12.vue

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,6 @@ function dynamicallyAddTitleHeader() {
259259
};
260260
columns.value.push(newCol);
261261
columns.value = columns.value.slice(); // or use spread operator [...cols]
262-
263-
// NOTE if you use an Extensions (Checkbox Selector, Row Detail, ...) that modifies the column definitions in any way
264-
// you MUST use "getAllColumnDefinitions()" from the GridService, using this will be ALL columns including the 1st column that is created internally
265-
// for example if you use the Checkbox Selector (row selection), you MUST use the code below
266-
/*
267-
const allColumns = vueGrid.gridService.getAllColumnDefinitions();
268-
allColumns.push(newCol);
269-
columns.value = [...allColumns]; // (or use slice) reassign to column definitions for Vue to do dirty checking
270-
*/
271262
}
272263
273264
function exportToExcel() {

0 commit comments

Comments
 (0)