Hi,I'm trying to add few dynamically generated columns (Application TextColumn + Attribute NumberColumns), to the grid. I want to have a group panel and be able to group by the text columns (Module and Application) and perform a sum on the remaining number columns. To achieve this I'm using the ParseJson_ToDynamicColumnsDynamicDataType action. After all the columns are loaded onto the grid I run the SetColumnAggregate funtion from the GridAPI and it seems to work fine, as the rows are are grouped correctly. The problem is that it's not actually doing the SUM function as intended (the highlighted values should SUM = 6 and it's showing 0)
If I do the same with the the aggregate funtion Entities.Aggregation.Last it's working as intended (see image bellow), which leads me to believe that the grid is not recognizing the column as a number but rather as a text.
How can I use the SetColumnAggregate funtion from the grid API over the dynamic columns?
Thanks for the help,Constança
Hello Constança!
Thank you for using our Asset!
I was able to verify that you are correct on your assumption. It seems the Datagrid is interpreting the values as text, even with us forcing it to use Numeric columns.
Currently, I'm not able to spend time fixing this issue.
If you are using the client side version of the ParseJson_ToDynamicColumnsDynamicDataType action, you could try to make some modification trying to cast the data[i]['CellValue'] to a decimal number. This is the value that is being considered as a string. This might work, for your case.
line 21 of js: current_dict[data[i]['DynamicColumnName']] = data[i]['CellValue']
Hi @Henrique Silva,Thanks for the reply! I tried formatting the JSON and convert to the columns with numbers to int using this code:
data = JSON.parse(String($parameters.JsonData))
data.data.forEach(item => {
// Check if the value can be converted to a number
const value = item.CellValue;
if (!isNaN(value)) {
// Convert the value to a number
item.CellValue = Number(value);
}
}); And the aggregates work now. Thanks!
Hello, I am having this problem right now. May I know where you put this code? Cause I got 'Unexpected end of JSON input' when I put it in the GridOnInitialize. Thank you.
@Constança Branco @Matanong
I have just released a new version of the Data Grid Dynamic Columns (v1.1.7) including the fix Constança suggested. It now properly sorts decimal columns and considers as decimal when using the DynamicDataType action.
Just for awareness, the asset is is now available on ODC!
Thank you Constança Branco for your contribution!