Read headers from RadGridView

4 posts, 1 answers
  1. Vivienne
    Vivienne avatar
    2 posts
    Member since:
    Mar 2013

    Posted 23 Apr 2013 Link to this post

    We are testing an application that uses the Telerik.Windows.Controls.RadGridView registers.

    I want to retrieve the values in the column headers.  Presumably I iterate through the gridview in some way getting the values.  I have tried a number of different methods with no luck.

    In the tree I can see that there is a GridViewHeaderRow and within that a Selective Scrolling Grid.  Then below that is a DataCellsPresenter wiht a number of Grid View Cells in a panel - the text value of hte headers are within these GridViewCells.

    I am struggling to work on the correct object in order to get the column header texts.  The objects I have attempted to use throw an error in the foreach statement to say that getenumerator has not been exposed.

    Has anyone successfully iterated through a selective scrolling grid?

    thanks


    [CodedStep(

     

    @"readHeaders")]

     

     

     

    public void requisitionScreen_CodedStep()

     

    {

     

     

    // read through the grid

     

    WpfApplication app = Manager.ActiveApplication;

    Assert.IsNotNull(app);

     

    Telerik.Windows.Controls.GridView.GridView grid = app.MainWindow.Find.ByName<Telerik.Windows.Controls.GridView.GridView>(

     

    "GridView");

     

     

    Telerik.Windows.Controls.GridViewHeaderRow row = grid.HeaderRow;

     

     

    int index=row.HeaderCells.Count;

     

    Log.WriteLine(

     

    "count "+index.ToString());

     

     

     

     

    for (int i=0;i<index;i++){

     

    row.HeaderCells[i].ToString();

     

    }

     

  2. Answer
    Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 25 Apr 2013 Link to this post

    Hello Vivienne,

    Since you are using a Telerik RadGridView for WPF control, you need to use the Telerik.WebAii.Controls.Xaml.Wpf namespace, which contains our control wrappers and translators for all Telerik WPF controls. Here's a sample code against one of our Telerik RadGridView demos:
    WpfApplication app = Manager.ActiveApplication;
    Assert.IsNotNull(app);
     
    Telerik.WebAii.Controls.Xaml.Wpf.RadGridView grid = app.MainWindow.Find.ByName<Telerik.WebAii.Controls.Xaml.Wpf.RadGridView>("RadGridView1");
    Assert.IsNotNull(grid);
     
     
    foreach (GridViewHeaderCell hCell in grid.HeaderRow.HeaderCells)
    {
        Log.WriteLine(hCell.TextBlockContent);
    }

    See this video demonstrating the execution. You should be able to use the code above against your application by simply replacing the grid name(RadGridView1) with the name of your grid.

    Please give it a try and let me know if you need further assistance on this.

    Regards,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Vivienne
    Vivienne avatar
    2 posts
    Member since:
    Mar 2013

    Posted 28 Apr 2013 Link to this post

    Hi

    My issue was that I was attempting to get the grid at a lower level.  With confirmation of the level that I required, this solution worked immediately.

    thanks
    Vivienne
  4. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 29 Apr 2013 Link to this post

    Hello Vivienne,

    I am glad to hear it! Thanks for the update. Please contact us again if you have further problems.

    Regards,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top