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

Read headers from RadGridView

3 Answers 34 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vivienne
Top achievements
Rank 1
Vivienne asked on 24 Apr 2013, 12:20 AM
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();

 

}

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Plamen
Telerik team
answered on 25 Apr 2013, 01:54 PM
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
0
Vivienne
Top achievements
Rank 1
answered on 28 Apr 2013, 11:29 PM
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
0
Plamen
Telerik team
answered on 29 Apr 2013, 09:30 AM
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
Tags
General Discussions
Asked by
Vivienne
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Vivienne
Top achievements
Rank 1
Share this question
or