Hi Johan,
Let me start with a question, so that I am sure I am getting this right -- you might have different kind of values within the same column, so that you might need one format on item 1 (row 1) and another on item 2, is that correct? In this case, the short answer is -- this cannot be done through CellContentFormat property of the column.
You can use DataGridTemplateColumn instead. You can place just a single TextBlock within the CellContentTemplate and bind it to the DataContext. Then you can add a converter, which in this case, will receive the entire business object, so that you can retrieve the value, the format and return the text to be shown as per your requirements.
And the converter might be similar to this:
Best regards,
Ves
Telerik
Let me start with a question, so that I am sure I am getting this right -- you might have different kind of values within the same column, so that you might need one format on item 1 (row 1) and another on item 2, is that correct? In this case, the short answer is -- this cannot be done through CellContentFormat property of the column.
You can use DataGridTemplateColumn instead. You can place just a single TextBlock within the CellContentTemplate and bind it to the DataContext. Then you can add a converter, which in this case, will receive the entire business object, so that you can retrieve the value, the format and return the text to be shown as per your requirements.
<telerikGrid:DataGridTemplateColumn> <telerikGrid:DataGridTemplateColumn.CellContentTemplate> <DataTemplate> <TextBlock Text="{Binding Converter={StaticResource converter}}"></TextBlock> </DataTemplate> </telerikGrid:DataGridTemplateColumn.CellContentTemplate></telerikGrid:DataGridAnd the converter might be similar to this:
public object Convert(object value, System.Type targetType, object parameter, string language) { MyDataItem data = value as MyDataItem; return data.Value.ToString(data.Format); }Best regards,
Ves
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items