Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROU-11649: Implemented RemoveColumnsFromGroupPanel API #447

Merged
merged 2 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"UI Components"
],
"devDependencies": {
"@types/lodash": "^4.17.6",
"@types/lodash": "^4.17.15",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"browser-sync": "^3.0.2",
Expand Down
1 change: 1 addition & 0 deletions src/OSFramework/DataGrid/Enum/ErrorCodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ namespace OSFramework.DataGrid.Enum {
API_FailedSetColumnWordWrap = 'GRID-API-10008',
API_FailedSetColumnHeader = 'GRID-API-10009',
API_FailedSetNumberAggregateConditionalFormatting = 'GRID-API-10010',
API_FailedRemoveColumnsFromGroupPanel = 'GRID-API-10011',
//EXPORT
API_FailedCustomizeExportingMessage = 'GRID-API-11001',
//COLUMNPICKER
Expand Down
7 changes: 6 additions & 1 deletion src/OSFramework/DataGrid/Feature/IGroupPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace OSFramework.DataGrid.Feature {
/** Boolean that indicates whether the grid is grouped or not */
isGridGrouped: boolean;
/**
* Add a given column to the grid group panel
* Add a given given column or columns list to the grid group panel
* @param binding binding of the column
*/
addColumnsToGroupPanel(binding: string): void;
Expand All @@ -13,6 +13,11 @@ namespace OSFramework.DataGrid.Feature {
* @param binding binding of the column
*/
columnInGroupPanel(binding: string): boolean;
/**
* Remove a given column or columns list from the grid group panel
* @param binding binding of the column
*/
removeColumnsFromGroupPanel(binding: string): void;
/**
* Sets the column aggregation function inside the Group Panel
* @param binding binding of the column
Expand Down
33 changes: 30 additions & 3 deletions src/OutSystems/GridAPI/ColumnManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ namespace OutSystems.GridAPI.ColumnManager {
const columnArr = new Array<OSFramework.DataGrid.Column.IColumn>();

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

const column = GetColumnById(columnID);
if(column === undefined){
if (column === undefined) {
throw new Error(OSFramework.DataGrid.Enum.ErrorMessages.Column_NotFound);
}

Expand Down Expand Up @@ -188,6 +188,33 @@ namespace OutSystems.GridAPI.ColumnManager {
);
}

/**
* Remove a given column or columns list from the grid group panel
*
* @export
* @param {string} gridID ID of the Grid where the change will occur.
* @param {string} ListOfColumnIDs List of Ids of the Column blocks that will be programmatically removed from the grid group panel.
*/
export function RemoveColumnsFromGroupPanel(gridID: string, ListOfColumnIDs: string): string {
Performance.SetMark('ColumnManager.RemoveColumnsFromGroupPanel');
const result = Auxiliary.CreateApiResponse({
gridID,
errorCode: OSFramework.DataGrid.Enum.ErrorCodes.API_FailedRemoveColumnsFromGroupPanel,
callback: () => {
GridManager.GetGridById(gridID).features.groupPanel.removeColumnsFromGroupPanel(ListOfColumnIDs);
},
});

Performance.SetMark('ColumnManager.RemoveColumnsFromGroupPanel-end');
Performance.GetMeasure(
'@datagrid-ColumnManager.RemoveColumnsFromGroupPanell',
'ColumnManager.RemoveColumnsFromGroupPanel',
'ColumnManager.RemoveColumnsFromGroupPanel-end'
);

return result;
}

/**
* Set column aggregate in group panel
*
Expand Down
30 changes: 30 additions & 0 deletions src/Providers/DataGrid/Wijmo/Features/GroupPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,36 @@ namespace Providers.DataGrid.Wijmo.Feature {
});
}

public removeColumnsFromGroupPanel(bindingList: string): void {
const groupDescriptions = this._grid.provider.collectionView.groupDescriptions; // Group array
const columnList = JSON.parse(bindingList);
const source = this._grid.provider.itemsSource;

source.deferUpdate(() => {
for (const binding of columnList) {
const column = this._grid.getColumn(binding);
if (column) {
// Find the index of the group description for the column's binding
const index = groupDescriptions.findIndex((gd) => {
if (gd instanceof wijmo.collections.PropertyGroupDescription) {
return gd.propertyName === column.config.binding;
}
return false;
});

// If the group description exists, remove it
if (index > -1) {
groupDescriptions.splice(index, 1);
// Make the column visible again
column.provider.visible = true;
}
} else {
throw new Error(OSFramework.DataGrid.Enum.ErrorMessages.InvalidColumnIdentifier);
}
}
});
}

public setAggregate(binding: string, aggregate: wijmo.Aggregate): void {
const column = this._grid.getColumn(binding);

Expand Down
Loading