Skip to content

Commit e9fa2cf

Browse files
fix encoded symbols when exporting csv
1 parent ae66304 commit e9fa2cf

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

src/OutSystems/GridAPI/ColumnManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace OutSystems.GridAPI.ColumnManager {
2626
'ColumnManager.AddColumnToGroupPanel-end'
2727
);
2828

29-
return JSON.stringify(result);
29+
return result;
3030
}
3131

3232
/**

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace Providers.DataGrid.Wijmo.Feature {
4646
this._grid.features.pagination.changePageSize(0);
4747
}
4848

49-
private _showLoadingMessage() {
49+
private _showLoadingMessage(): void {
5050
const parentPlaceholder = OSFramework.DataGrid.Helper.GetElementByUniqueId(
5151
this._grid.uniqueId
5252
).parentElement;
@@ -58,6 +58,12 @@ namespace Providers.DataGrid.Wijmo.Feature {
5858
parentPlaceholder.appendChild(createdDivElem);
5959
}
6060

61+
// Workaround for HTML tags being exported in CSV with Grouped Columns
62+
private _stripHtmlTags(htmlString: string): string {
63+
if (!htmlString) return '';
64+
return htmlString.replace(/<(?!>)[a-zA-Z0-9/][^>]*>/g, '');
65+
}
66+
6167
public build(): void {
6268
return;
6369
}
@@ -101,7 +107,7 @@ namespace Providers.DataGrid.Wijmo.Feature {
101107
this._resetPagination();
102108

103109
const params = { fileName: this._handleFilename(filename, true) };
104-
const result = this._grid.provider.getClipString(this._getFullCellRange(), true, true);
110+
const result = this._stripHtmlTags(this._grid.provider.getClipString(this._getFullCellRange(), true, true));
105111

106112
this._reApplyPagination();
107113
wijmo.saveFile(result, params.fileName);

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace Providers.DataGrid.Wijmo.Feature {
3838
OSFramework.DataGrid.Interface.IBuilder,
3939
OSFramework.DataGrid.Interface.IDisposable
4040
{
41-
private _currGroupDescription: Array<wijmo.collections.PropertyGroupDescription>;
41+
private _currGroupDescription = new Array<wijmo.collections.PropertyGroupDescription>();
4242
private _grid: Grid.IGridWijmo;
4343
private _groupPanel: wijmo.grid.grouppanel.GroupPanel;
4444
private _panelId: string;
@@ -104,11 +104,33 @@ namespace Providers.DataGrid.Wijmo.Feature {
104104
o: wijmo.collections.ObservableArray /*,
105105
e: wijmo.collections.NotifyCollectionChangedEventArgs*/
106106
) => {
107+
const grid = this._grid;
108+
107109
//Add and close to the Stack the global value with the last config
108-
this._grid.features.undoStack.startAction(
109-
new GroupPanelAction(this._grid.provider, this._currGroupDescription)
110+
grid.features.undoStack.startAction(
111+
new GroupPanelAction(grid.provider, this._currGroupDescription)
110112
);
111-
this._grid.features.undoStack.closeAction(GroupPanelAction);
113+
grid.features.undoStack.closeAction(GroupPanelAction);
114+
115+
const newGroupedDescriptions = o.filter((gd) => !this._currGroupDescription.includes(gd));
116+
const ungroupedDescriptions = this._currGroupDescription.filter((gd) => !o.includes(gd));
117+
118+
// Workaround for HTML tags and encoded symbols being exported in CSV when the Grid present Grouped Columns.
119+
// Loop through the columns just added to the Group Panel and set isContentHtml to true.
120+
newGroupedDescriptions.forEach(function (groupDesc: wijmo.collections.PropertyGroupDescription) {
121+
const col = grid.provider.getColumn(groupDesc.propertyName);
122+
if (col) {
123+
col.isContentHtml = true;
124+
}
125+
});
126+
127+
// Loop through the group descriptions just removed from the Group Panel and set isContentHtml to false.
128+
ungroupedDescriptions.forEach(function (groupDesc: wijmo.collections.PropertyGroupDescription) {
129+
const col = grid.provider.getColumn(groupDesc.propertyName);
130+
if (col) {
131+
col.isContentHtml = false;
132+
}
133+
});
112134

113135
//Updates the global variable wih the current config
114136
this._currGroupDescription = o.slice();

0 commit comments

Comments
 (0)