I have developed a data entry application that utilizes the DataGrid component from DevExpress (devextreme) to allow users to add and remove columns, excluding the key column. The column configuration and user data are both stored in an SQL database. Here is a sample of the user data format:
Key | ColumnName | ColumnValue
-------------------------------------
1 Company Apple
1 NumberOfEmployees 12345
The data is then pivoted before being sent to the grid:
Key | Company | NumberOfEmployees
---------------------------------
1 Apple 12345
When a user updates a row in the grid, the grid returns a data object containing properties for each column. I am using the column definition to try to match these properties, but the results are not as expected:
const userColumns: any[] = [
{
ColumnName: 'Company'
}, {
ColumnName: 'NumberOfEmployees'
}
];
const returnedFromGridRow: Record<string, any> = {};
returnedFromGridRow.Company = 'Apple';
returnedFromGridRow.NumberOfEmployees = 12345;
let result: Record<string, any> = {};
const results: any = [];
userColumns.forEach(function (value) {
let x: string = value.ColumnName;
let y: string = returnedFromGridRow[x];
result = {x:y};
console.log(result);
results.push(result);
});
Expected Output:
{ "Company" : "Apple" }
{ "NumberOfEmployees" : 12345 }
Actual Output:
{ "x" : "Apple" }
{ "x" : 12345 }