Not able to identify Automation ID inside RadGridView cell Template

17 posts, 0 answers
  1. Dilip
    Dilip avatar
    23 posts
    Member since:
    Jun 2013

    Posted 09 Feb 2015 Link to this post

    Hi,

    Please anyone let us know how to identify the automation id for the control inside the RadGridview cell Template.
    Below is the code sample which i tried by giving the automation id but unable to find the id control.

     <telerik:GridViewDataColumn Header="######"
                                                IsSortable="True"
                                                IsReadOnly="True"
                                                UniqueName="#######">
                        <telerik:GridViewDataColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding ########}"
                                           AutomationProperties.AutomationId="{Binding Path=#######, StringFormat='##########_{0}'}"></TextBlock>
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 09 Feb 2015 Link to this post

    Hello Dilip,

    Will it be possible to clarify what your exact scenario is ? Do you want to set custom automation id to an element or probably find the element in a way ? 

    Regards,
    Maya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
  4. Dilip
    Dilip avatar
    23 posts
    Member since:
    Jun 2013

    Posted 23 Feb 2015 in reply to Maya Link to this post

    Hello Maya,

    I need to find the automation id inside the element of the cell. I hope, i have answered your question. 

    Thanks,
    Dilip L.
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 24 Feb 2015 Link to this post

    Hi Dilip,

    Currently, each element inside the cell will receive a predefined AutomationID that follows the format: 
    AutomationProperties.SetAutomationId(childElement, string.Format("CellElement_{0}_{1}", this.OwnerCell.ParentDataControl.Items.IndexOf(this.OwnerCell.ParentRow.Item), this.OwnerCell.Column.DisplayIndex));

    As for finding and working with the AutomationID, you can find more information in here: 
    1. Use the AutomationID property
    2. Coded UI tests : AutomationId or how to find the chose one (control) !

    Regards,
    Maya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Rajendar
    Rajendar avatar
    69 posts
    Member since:
    Jun 2013

    Posted 05 Mar 2015 in reply to Maya Link to this post

    Hi Maya,

    Can I not bind AutomationProperties.AutomationId to some property in XAML ?

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" AutomationProperties.AutomationId="{Binding Name}"/> 

    Because I do not want using default Automation Id (which contains index)

    Regards,
    Rajendar. 
  7. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 05 Mar 2015 Link to this post

    Hello Rajendar,

    GridViewDataColumn (or any other column) is not a visual element and does not have automation properties. What you can try instead is to work with GridViewCell and set its AutomationId property: 
    <Style TargetType="telerik:GridViewCell">
              <Setter Property="AutomationProperties.AutomationId" Value="{Binding Value, RelativeSource={RelativeSource Self}}" />
          </Style>



    Regards,
    Maya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  8. Rajendar
    Rajendar avatar
    69 posts
    Member since:
    Jun 2013

    Posted 05 Mar 2015 in reply to Maya Link to this post

    Hi Maya,

    Thank you for quick responds.

    Is anything wrong in my code
    -------------------------------------
       <Window.Resources>
            <Style TargetType="telerik:GridViewRow">
                <Setter Property="AutomationProperties.AutomationId" Value="{Binding Value,RelativeSource={RelativeSource Self}}" />
            </Style>    
        </Window.Resources>    
        <Grid x:Name="LayoutRoot" >
            <telerik:RadTreeListView x:Name="radTreeListView"
                                AutoGenerateColumns="False" ShowColumnHeaders="False" >         
                <telerik:RadTreeListView.Columns>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>                
                </telerik:RadTreeListView.Columns>
            </telerik:RadTreeListView>
        </Grid> 
    ==============
    Here name is property.
    I am till seeing default automation id only

    Regards,
    Rajendar.

  9. Rajendar
    Rajendar avatar
    69 posts
    Member since:
    Jun 2013

    Posted 05 Mar 2015 in reply to Rajendar Link to this post

    Hi Maya,

    Thank you for quick responds.

    Is anything wrong in my code
    -------------------------------------
       <Window.Resources>
            <Style TargetType="telerik:GridViewRow">
                <Setter Property="AutomationProperties.AutomationId" Value="{Binding Name,RelativeSource={RelativeSource Self}}" />
            </Style>    
        </Window.Resources>    
        <Grid x:Name="LayoutRoot" >
            <telerik:RadTreeListView x:Name="radTreeListView"
                                AutoGenerateColumns="False" ShowColumnHeaders="False" >         
                <telerik:RadTreeListView.Columns>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>                
                </telerik:RadTreeListView.Columns>
            </telerik:RadTreeListView>
        </Grid> 
    ==============
    Here name is property.
    I am till seeing default automation id only

    Regards,
    Rajendar.
  10. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 05 Mar 2015 Link to this post

    Hi Rajendar,

    When you use the binding:
    Value="{Binding Name,RelativeSource={RelativeSource Self}}"

    That suggests you have property "Name" of each object of type GridViewRow. 
    I am guessing that you want to bind to a property from your business object that has such "Name" property. If so, you do the following: 
    <Style TargetType="telerik:GridViewRow">
              <Setter Property="AutomationProperties.AutomationId" Value="{Binding Name}" />
          </Style>



    Regards,
    Maya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  11. Rajendar
    Rajendar avatar
    69 posts
    Member since:
    Jun 2013

    Posted 05 Mar 2015 in reply to Maya Link to this post

    Hi Maya,

    Thanks for your help.

    But that is also not working in my case
    --------------------------
    <Window.Resources>
            <Style TargetType="telerik:GridViewRow" >
                <Setter Property="AutomationProperties.AutomationId" Value="{Binding Name}" />
            </Style>
        </Window.Resources>    
        <Grid x:Name="LayoutRoot" >
            <telerik:RadTreeListView x:Name="radTreeListView"
                                AutoGenerateColumns="False" ShowColumnHeaders="False" >
                <telerik:RadTreeListView.Columns>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
                </telerik:RadTreeListView.Columns>
            </telerik:RadTreeListView>
        </Grid>
    -------------------
    Can you please provide any sample application?
    Regards,
    Rajendar.
  12. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 05 Mar 2015 Link to this post

    Hi Rajendar,

    I attach a sample project illustrating the behavior and it seems to work correctly. Do you get different behavior on your side ? 

    Regards,
    Maya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  13. Rajendar
    Rajendar avatar
    69 posts
    Member since:
    Jun 2013

    Posted 05 Mar 2015 in reply to Maya Link to this post

    Hi Maya,

    It is working as expected in RadGridView but not working RadTreeListView.

    Why it is not working in RadTreeListView ?
    Can you help me to provide unique AutomationId for RadTreeListView Row?

    Regards,
    Rajendar.
  14. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 05 Mar 2015 Link to this post

    Hi,

    Depending on which control you are working with, you need to target GridViewRow or TreeListViewRow. In case of using RadTreeListView, the setting should be:
    <Style TargetType="telerik:TreeListViewRow" >
              <Setter Property="AutomationProperties.AutomationId" Value="{Binding Name}" />
          </Style>



    Regards,
    Maya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  15. Rajendar
    Rajendar avatar
    69 posts
    Member since:
    Jun 2013

    Posted 05 Mar 2015 in reply to Maya Link to this post

    Hi Maya,

    Thank you for your help.
    Actually I am using  2014.2.0729.45. It is not working in this version. Even if I replace these dlls in sample application which you have provided , CUIT is showing default Automation Id.
    Did you fix this issue in latest version. If yes please tell me from which this fix is available?

    Regards,
    Rajendar.
  16. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 05 Mar 2015 Link to this post

    Hello,

    Indeed, there used to be an issue that custom AutomationId and Name properties are not respected and I resolved it in one of our internal builds in September. The fix is available from Q3 2014 release. 

    Regards,
    Maya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  17. Rajendar
    Rajendar avatar
    69 posts
    Member since:
    Jun 2013

    Posted 05 Mar 2015 in reply to Maya Link to this post

    Hi Maya,

    Thanks for your information.
    I have tested in 2014 Q3. It is working fine with Automation Id but look like there an issue with name property.
    Did you fix this issue in latest version. If yes please let me the version?

    Regards,
    Rajendar.
  18. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 05 Mar 2015 Link to this post

    Hi Rajendar,

    It turns out the behavior for Name property for TreeListViewRow does not support custom values. I updated that and the fix will be available in our next internal build coming on Monday. 
    I also updated your Telerik points. 


    Regards,
    Maya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
DevCraft banner