RadGridViewColumn - UniqueName

1 Answer 20 Views
GridView PersistenceFramework
alex
Top achievements
Rank 1
Iron
Iron
Iron
alex asked on 07 Sep 2022, 07:39 PM

Hi,

I saw in other question that someday you will turn the UniqueName property into obsolete.

I need to save some configuration about the GridViewColumns to a file. I saw that when I use DataMemberBinding, the UniqueName name holds the Binding property name, but if I define a cell template without data member binding, the UniqueName property is null. How can I guarante the uniquenes of a column identifier? even if I put DataMemberBinding in all columns, theoretically I can have the same UniqueName name twice (binding two same property twice and showing different path in the cell template of the column).

 

It is not logical to call a property UniqueName without being unique. Can you help me please ??

How do you guarantee the uniqueness in your PersistenceManager implementation??

 

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 12 Sep 2022, 08:40 AM

Hello Alex,

When using GridViewDataColumn it is recommended to use the DataMemberBinding whether you are using the CellTemplate or not. The DataMemberBinding is used by the GridView to properly filter, sort and group the corresponding column. The CellTemplate on the other hand defines only the visualization of the cells in the column.

The GridView doesn't promise generating UniqueNames for the column. It tries to do this using the property name fetched from the DataMemberBinding, but as you said you may have duplicated property names. The idea of the UniqueName is to allow the developer to name the column and use it if needed.

If you want to guarantee an unique name, you can manually set the property of the column. If your columns are autogenerated you can use the AutoGeneratingColumn event of RadGridView. For example:

private void gridView_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)  
{  
	e.Column.UniqueName = Guid.NewGuid().ToString();
} 

At this point we don't have plans to obsolete or move the UniqueName property.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
GridView PersistenceFramework
Asked by
alex
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or