Skip to content

Commit 72bb41c

Browse files
authored
ROU-11649: Implemented RemoveColumnsFromGroupPanel API (#447)
* Implemented RemoveColumnsFromGroupPanel APIs * Fixed typo on addColumnsToGroupPanel comment
1 parent cdb7ee0 commit 72bb41c

File tree

5 files changed

+68
-5
lines changed

5 files changed

+68
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"UI Components"
3131
],
3232
"devDependencies": {
33-
"@types/lodash": "^4.17.6",
33+
"@types/lodash": "^4.17.15",
3434
"@typescript-eslint/eslint-plugin": "^5.62.0",
3535
"@typescript-eslint/parser": "^5.62.0",
3636
"browser-sync": "^3.0.2",

src/OSFramework/DataGrid/Enum/ErrorCodes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ namespace OSFramework.DataGrid.Enum {
8383
API_FailedSetColumnWordWrap = 'GRID-API-10008',
8484
API_FailedSetColumnHeader = 'GRID-API-10009',
8585
API_FailedSetNumberAggregateConditionalFormatting = 'GRID-API-10010',
86+
API_FailedRemoveColumnsFromGroupPanel = 'GRID-API-10011',
8687
//EXPORT
8788
API_FailedCustomizeExportingMessage = 'GRID-API-11001',
8889
//COLUMNPICKER

src/OSFramework/DataGrid/Feature/IGroupPanel.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace OSFramework.DataGrid.Feature {
44
/** Boolean that indicates whether the grid is grouped or not */
55
isGridGrouped: boolean;
66
/**
7-
* Add a given column to the grid group panel
7+
* Add a given column or columns list to the grid group panel
88
* @param binding binding of the column
99
*/
1010
addColumnsToGroupPanel(binding: string): void;
@@ -13,6 +13,11 @@ namespace OSFramework.DataGrid.Feature {
1313
* @param binding binding of the column
1414
*/
1515
columnInGroupPanel(binding: string): boolean;
16+
/**
17+
* Remove a given column or columns list from the grid group panel
18+
* @param binding binding of the column
19+
*/
20+
removeColumnsFromGroupPanel(binding: string): void;
1621
/**
1722
* Sets the column aggregation function inside the Group Panel
1823
* @param binding binding of the column

src/OutSystems/GridAPI/ColumnManager.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ namespace OutSystems.GridAPI.ColumnManager {
33
const columnArr = new Array<OSFramework.DataGrid.Column.IColumn>();
44

55
/**
6-
* Add a given column to the grid group panel.
6+
* Add a given column or columns list to the grid group panel.
77
*
88
* @export
99
* @param {string} gridID ID of the Grid where the change will occur.
10-
* @param {string} columnID ID of the Column block that will be programmatically added to the grid group panel.
10+
* @param {string} ListOfColumnIDs List of Ids of the Column blocks that will be programmatically added to the grid group panel.
1111
*/
1212
export function AddColumnsToGroupPanel(gridID: string, ListOfColumnIDs: string): string {
1313
Performance.SetMark('ColumnManager.AddColumnToGroupPanel');
@@ -144,7 +144,7 @@ namespace OutSystems.GridAPI.ColumnManager {
144144
Performance.SetMark('ColumnManager.changeProperty');
145145

146146
const column = GetColumnById(columnID);
147-
if(column === undefined){
147+
if (column === undefined) {
148148
throw new Error(OSFramework.DataGrid.Enum.ErrorMessages.Column_NotFound);
149149
}
150150

@@ -188,6 +188,33 @@ namespace OutSystems.GridAPI.ColumnManager {
188188
);
189189
}
190190

191+
/**
192+
* Remove a given column or columns list from the grid group panel
193+
*
194+
* @export
195+
* @param {string} gridID ID of the Grid where the change will occur.
196+
* @param {string} ListOfColumnIDs List of Ids of the Column blocks that will be programmatically removed from the grid group panel.
197+
*/
198+
export function RemoveColumnsFromGroupPanel(gridID: string, ListOfColumnIDs: string): string {
199+
Performance.SetMark('ColumnManager.RemoveColumnsFromGroupPanel');
200+
const result = Auxiliary.CreateApiResponse({
201+
gridID,
202+
errorCode: OSFramework.DataGrid.Enum.ErrorCodes.API_FailedRemoveColumnsFromGroupPanel,
203+
callback: () => {
204+
GridManager.GetGridById(gridID).features.groupPanel.removeColumnsFromGroupPanel(ListOfColumnIDs);
205+
},
206+
});
207+
208+
Performance.SetMark('ColumnManager.RemoveColumnsFromGroupPanel-end');
209+
Performance.GetMeasure(
210+
'@datagrid-ColumnManager.RemoveColumnsFromGroupPanell',
211+
'ColumnManager.RemoveColumnsFromGroupPanel',
212+
'ColumnManager.RemoveColumnsFromGroupPanel-end'
213+
);
214+
215+
return result;
216+
}
217+
191218
/**
192219
* Set column aggregate in group panel
193220
*

src/Providers/DataGrid/Wijmo/Features/GroupPanel.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,36 @@ namespace Providers.DataGrid.Wijmo.Feature {
161161
});
162162
}
163163

164+
public removeColumnsFromGroupPanel(bindingList: string): void {
165+
const groupDescriptions = this._grid.provider.collectionView.groupDescriptions; // Group array
166+
const columnList = JSON.parse(bindingList);
167+
const source = this._grid.provider.itemsSource;
168+
169+
source.deferUpdate(() => {
170+
for (const binding of columnList) {
171+
const column = this._grid.getColumn(binding);
172+
if (column) {
173+
// Find the index of the group description for the column's binding
174+
const index = groupDescriptions.findIndex((gd) => {
175+
if (gd instanceof wijmo.collections.PropertyGroupDescription) {
176+
return gd.propertyName === column.config.binding;
177+
}
178+
return false;
179+
});
180+
181+
// If the group description exists, remove it
182+
if (index > -1) {
183+
groupDescriptions.splice(index, 1);
184+
// Make the column visible again
185+
column.provider.visible = true;
186+
}
187+
} else {
188+
throw new Error(OSFramework.DataGrid.Enum.ErrorMessages.InvalidColumnIdentifier);
189+
}
190+
}
191+
});
192+
}
193+
164194
public setAggregate(binding: string, aggregate: wijmo.Aggregate): void {
165195
const column = this._grid.getColumn(binding);
166196

0 commit comments

Comments
 (0)