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

RadGridView Localised columns doesnot pick proper AutomationProperties.AutomationId

6 Answers 43 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Usman
Top achievements
Rank 1
Usman asked on 30 Sep 2019, 07:27 AM

Dear Telerik team,

We have a RadGridView with localised columns and we would like to use string that remain same for all localised value. In order to achieve we use UniqueName="Id" and Set AutomationProperties.AutomationId="{Binding UniqueName, RelativeSource={RelativeSource Self}}" but when we run application the Header which is a localised string always get precedence and we end up with header value.

Here is a code there we were using for defining columns

<telerik:GridViewDataColumn
                    x:Name="OrderId"
                    Width="auto"
                    AutomationProperties.AutomationId="{Binding UniqueName, RelativeSource={RelativeSource Self}}"                     DataMemberBinding="{Binding Id}"
                    Header="{x:Static resources:Resources.Id}"
                    Style="{StaticResource RightAlignedRadGridViewColumnStyle}"
                    UniqueName="OrderId">

6 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 02 Oct 2019, 04:18 PM

Hello Usman,

Thank you for the provided code snippet. 

May I ask you to elaborate a bit on the described scenario? Can you share what you mean by "when we run application the Header which is a localised string always get precedence and we end up with header value."? Where is the header value applied? Can you share some sample pictures demonstrating the observed on your end result and elaborate on what is the desired behavior? This will hopefully allow me to better understand the scenario and think of an appropriate suggestion. 

I am looking forward to your reply. 

Regards,
Vladimir Stoyanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Usman
Top achievements
Rank 1
answered on 03 Oct 2019, 03:15 PM

Hi Vladimir,

Thanks for your response,

"when we run application the Header which is a localised string always get precedence and we end up with header value."
Localised string is used in application using resources for Header property of telerik:GridViewDataColumn as I shared already in the code snippet above.

You can also observe that AutomationId is binded to UniqueName and unique name has also been defined.

The resultant binded value which is localised string is displayed.

I am attaching two snapshots

MainWindow displaying the header with localised string

LiveProperties displaying the AutomationId.

Do let me know if you need more info.

 

0
Accepted
Dilyan Traykov
Telerik team
answered on 08 Oct 2019, 01:52 PM

Hi Usman,

If I correctly understood your requirement, you wish to have the UniqueName of the column (OrderId) as the AutomationId of the GridViewHeaderCell while still displaying the localized string as the Header (Reihenfolge). Please correct me if I'm wrong in this assumption.

If this is indeed the case, please note that the header cells will not acquire the AutomationId of their parent column automatically. You need to do this manually by creating the following style for these elements:

        <Style TargetType="telerik:GridViewHeaderCell">
            <Setter Property="AutomationProperties.AutomationId" Value="{Binding Column.UniqueName, RelativeSource={RelativeSource Self}}" />
        </Style>
I've prepared a small sample project to demonstrate this in action. Please note that I've used a random localization string (GridViewClearFilter) just for testing purposes.

Please have a look and let me know if a similar approach would work at your end.

Regards,
Dilyan Traykov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Usman
Top achievements
Rank 1
answered on 14 Oct 2019, 09:25 AM

Hi Dilyan,

Yes, your assumption is right.

Your suggested style does resolve required problem but the actual issue was that name property of column (x:Name) also get changed as per the header title which in my opinion it shouldn't.

Can you please help me understand if I am thinking the otherway?

0
Dilyan Traykov
Telerik team
answered on 14 Oct 2019, 01:57 PM

Hi Usman,

Even though the GridViewColumn element inherits from FrameworkContentElement (thus inheriting the Name property) it is not actually used by the column.

Can you please specify why you need to use the Name property and not the UniqueName and/or DataMemberBinding.Path.Path properties which will return the name of the bound source property instead?

Regards,
Dilyan Traykov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Usman
Top achievements
Rank 1
answered on 18 Oct 2019, 08:48 AM

Hi Dilyan,

Your suggested style already helped in achieving desired behaviour but as we usually used the name of control and bind them to automation id but in case of GridView Columns the name of control changes based on header value and I was just curious about this behaviour. 

Thanks for your help.

Tags
GridView
Asked by
Usman
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Usman
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or