Good day.
I would like to use the CellContentTemplateSelector and AutoGenerateColumns in RadDataGrid control.
In your description(https://docs.telerik.com/devtools/universal-windows-platform/controls/raddatagrid/columns/how-to/datagrid-howto-usecellcontenttemplateselectorproperty) there is such use, but it is not for cases when AutoGenerateColumns is on.
How can I set an event handler similar to "AutoGeneratingColumn" (in WPF) which I can not find in the RadDadaGrid for UWP?
Or is there some other solution?
P.S.I would have been satisfied with the program method for processing the event of automatic column generation, but I can not find this event. (like AutoGeneratingColumn in WPF )
4 Answers, 1 is accepted
RadDataGrid for UWP provides a command for column generation. The GenerateColumn command can be used for customizing the logic for automatic generation of grid columns. For more details how to implement this please take a look at the following link: DataGrid: GenerateColumn Command.
I hope the provided information could help.
Regards,
Didi
Progress Telerik
Thanks for the answer.
Now I have another problem. My columns are not generated.
<
controls:RadDataGrid
x:Name
=
"TableViewRelatedObjects"
HorizontalAlignment
=
"Stretch"
DataContext
=
"{x:Bind ViewModel}"
ItemsSource
=
"{x:Bind ViewModel.Items, Mode=OneWay}"
AutoGenerateColumns
=
"True"
UserGroupMode
=
"Disabled"
>
</
controls:RadDataGrid
>
public class MyViewModel : ModelBase
{
public ObservableCollection<
IRelatedListObject
> Items { get; set; }
}
public interface IRelatedListObject
{
string ObjectId { get; set; }
string LocalId { get; set; }
string ObjectType { get; set; }
bool CanDelete { get; set; }
}
As a result, only 4 columns are generated on the properteis which are described in the interface, but not the rest.
ItemSource and the result of the generation on the attached pictures.
Thank you for the provided code.
In order to show columns when the RadDataGrid GenerateColumCommand is used you should implement a custom logic inside the Execute method. The custom logic should specify for which property form the business object, the command could generate a column and its type.
I have prepared a sample project how this could be achieved. Please take a look at it and let me know if you have any other questions.
Regards,
Didi
Progress Telerik
Thanks for the answer, I realized my mistake. I had to use dynamic properties. So I changed the ViewModel:
public class MyViewModel : ModelBase
{
public ObservableCollection<
System.Dynamic.ExpandoObject
> Items { get; set; }
}
Generating columns works fine now!