3 Answers, 1 is accepted
Thank you for using our RadControls for Windows 8.
I have attached an example project demonstrating how to update your grid rows through the ItemsSource property of the grid.
I hope this helps.
Rositsa Topchiyska
Telerik
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Thanks for the feedback;
Working with the DataGridCellInfo, or similar, is it possible to populate a specific column/row cell;
The below code sample iterates thru a collection, and if the column title is changed - a new column is added;
The goal is to populate a cell, based on a column heading;
Thanks in advance for any insight;
for
(
int
i = 0; i < scI; i++)
{
if
(collectionScorecard[i].RegionName != columnTitle)
{
columnTitle = collectionScorecard[i].RegionName;
DataGridTextColumn textColumnRGN =
new
DataGridTextColumn() { PropertyName =
"Metric"
, Header = columnTitle };
ScenariosNew.Columns.Add(textColumnRGN);
}
}
Thank you for your question.
Let me clarify how the RadDataGrid control works. The grid is not a spreadsheet - you cannot add arbitrary values in the cells. It needs a collection of business objects as an ItemsSource and each row of the grid corresponds to an item of this collection. The grid columns have to be bound to real properties of the business objects. If the column is bound to a nonexistent property, the cells in that column will be empty.
You can implement your custom logic for adding columns (on adding new object for example), but remember that the items in the ItemsSource collection correspond to a grid row, not to a single cell.
If you don’t know initially the properties of your objects, a possible solution is to use dynamic objects, but note that the schema of the grid will be determined by the properties of the first dynamic object in the collection. If the following objects have different properties, then the grid will not generate columns for these properties. Or if you add columns for the new properties, you will end up with empty cells for the objects that don't have such properties.
I hope this makes things clear and let us know if there is anything else we can assist you with.
Rositsa Topchiyska
Telerik
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.