Hi All,
How to set the default value for the data grid dropdown column?
I have a score column with dropdown values (1, 2, 3). So, when the grid is initialized, can we set the default value as 1 for each row of the score column?
Regards,
Vinod
Hi @Vinod Kumar R
The dropdown values come from the database so you need to manage that at the database level when it's a foreign key from another entity.
In your case, given the fact you're using a different data source with no relation to the Product entity you can add the following script on the Initialize event handler from the Grid block:
let flexGrid = OutSystems.GridAPI.GridManager.GetGridById($parameters.GridWidgetId).provider; // Set the default value for the dropdown column in the initial data flexGrid.itemsSource.items.forEach(function (item) { // If Score has no value if (item.Score == null || item.Score == undefined || item.Score === '') { // set the ID of the Score to set as default item.Score = 3; } });
Hope it helps!
Cheers,GM
Thanks @Gonçalo Martins