I want to binding some properties to gridview programmatically. I have object hierarchy like that:
The datasource will be a list of CLASS_A, and i want to bind propA from CLASS_A and some properties of CLASS_B.
There is no problem to binding properties from CLASS_A with field name, but I try same doing something like "propC.propA" but doesnt work.
What I am doing wrong?
Thank you and Regards!!!
8 Answers, 1 is accepted
This should work but you need to have public properties in your classes. An example is available here: Binding to Sub Objects | RadGridView.
I hope this will be useful. Let me know if you have additional questions.
Thanks for your reply. Properties are public, but I write wrong my example :/
CLASS_A propC is "Object" type declared. But the specific type is "CLASS_B".How can I solve this?
Thank you and regards! :)
In this case, you will need to manually set the text of the cell. Here is an example valid for the code from the article:
I have attached a complete project as well.
Should you have any other questions do not hesitate to ask.
That worked perfectly :)
Thank you very much Dimitar, Best regards!
I got other issue related with this post. Bindings works OK, but now filtering and grouping doesnt work.
I have been searching o the documentation and I dont see nothing about it. What i must change for search and grouping work correctly?
Please make sure that the EnableFiltering and EnableGrouping properties of the RadGridView in your project are set to true. I am also able to filter the grid in the project my colleague sent previously. However, please note that if you group by the Car property and its type is object it will create a single group and also the available fields will be for type object. If you are still having the Car property defined with type object in order to group and filter by it, you can consider using CustomFiltering and CustomGrouping:
Additionally, you may also consider creating a custom type converter which will be responsible for formatting the text in the cells and creating a new Car object whenever you edit the Car column. You can follow the example demonstrated here: https://docs.telerik.com/devtools/winforms/gridview/columns/converting-data-types.
I am using type object and groups and filters doesnt work in that columns.
I am trying with customGrouping event, but GroupKey comes empty :/
The group key will come empty because with custom grouping it is your responsibility to set it and define how many groups you will have. This is also demonstrated in the code snippet of the CustomGrouping event handler: https://docs.telerik.com/devtools/winforms/gridview/grouping/custom-grouping. Generally speaking, setting the type of the property in this scenario to object is not support. If possible please consider defining it with its actual type.