This is a migrated thread and some comments may be shown as answers.

GridViewDataColumn - Bind header to class indexer

1 Answer 100 Views
GridView
This is a migrated thread and some comments may be shown as answers.
n/a
Top achievements
Rank 1
n/a asked on 12 Mar 2021, 01:29 PM

All,

I have a radgridview bound to a collection of custom objects. Is it possible to bind the GridViewDataColumn.Header property to the class indexer ?

e.g. public string this[string field] { …… }

 

Thanks in advance

 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Vladimir Stoyanov
Telerik team
answered on 17 Mar 2021, 08:18 AM

Hello Jason,

By default the DataContext of the columns is the DataContext of the RadGridView. With this in mind, you can bind the Header to the indexer directly, if it is defined in the DataContext of the control. If the indexer is within the custom objects in the ItemsSource, you have to access it through the collection in the viewmodel.

I am attaching a small sample project demonstrating both of the above mentioned approaches.

Regards,
Vladimir Stoyanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
GridView
Asked by
n/a
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Share this question
or