GridViewDataColumn name vs header

1 Answer 89 Views
Data Virtualization GridView
Gennady
Top achievements
Rank 2
Iron
Iron
Gennady asked on 30 Mar 2023, 06:29 PM | edited on 30 Mar 2023, 08:37 PM

Programmatically i'm selecting cells in RadGridView based on row and column. Search is done by column name and cell value. Grid records binded to the model by record properties. In my case column name could be different from record' property name, ex. translated to another language. Im wonder if there are a way to handle internaly record's column names but show on the grid custom names instead?

Binding is done by behavior:RadGridCustomBindingBehavior.Columns="{Binding GridColumns}", so [DisplayName("CustomColumnName")] is not applyed to the grid

Thank you

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 03 Apr 2023, 02:05 PM

Hello Gennady,

To achieve your requirement, you can assign the Header property of the columns. If you don't define the columns manually, but rely on the auto-generation feature, then you can use the AutoGeneratingColumn event of RadGridView, in order to access each column and set its Header.

Alternatively, you can use the DisplayAttribute as described in the help documentation.

I hope that helps.

Regards,
Martin Ivanov
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.

Gennady
Top achievements
Rank 2
Iron
Iron
commented on 05 Apr 2023, 01:15 AM

Did update header in dynamic columns creation process:

.cs:

_gridColumns.Add(new GridViewDataColumn() { DataMemberBinding = new System.Windows.Data.Binding("Name"), Header = "Full Name", IsVisible = true });

xaml:

AutoGenerateColumns="False"

behavior:RadGridCustomBindingBehavior.Columns="{Binding GridColumns}"

and it is working great.

Thank you, Martin, for fast respond!

Tags
Data Virtualization GridView
Asked by
Gennady
Top achievements
Rank 2
Iron
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or