Hello Telerik Team,
I create a test method:
When .I start this test, the value of "rowsCount" is 19, but really in radGridView1 we have > 50 rows, so why is this difference?
Thank you in advance!
I create a test method:
[Timeout(900000), TestMethod]
public void CheckRadGridViewRowsCountTest()
{
//Manager.LaunchNewBrowser();
Manager.LaunchNewBrowser(BrowserType.InternetExplorer, true);
ActiveBrowser.AutoWaitUntilReady = true;
ActiveBrowser.Window.SetActive();
ActiveBrowser.Window.SetFocus();
ActiveBrowser.Window.Maximize();
ActiveBrowser.NavigateTo(@"http://demos.telerik.com/silverlight/#GridView/Sorting");
// Get an instance of the running Silverlight Application.
app = ActiveBrowser.SilverlightApps()[0];
ActiveBrowser.RefreshDomTree();
// Get an instance of the running Silverlight Application.
app = ActiveBrowser.SilverlightApps()[0];
app.VisualTree.Find.Strategy = FindStrategy.AlwaysWaitForElementsVisible;
app.VisualTree.Find.WaitOnElementsTimeout = timeout;
RadGridView radGridView1 = app.VisualTree.Find.ByAutomationId<
RadGridView
>("RadGridView1");
var rowsCount = radGridView1.Rows.Count;
}
When .I start this test, the value of "rowsCount" is 19, but really in radGridView1 we have > 50 rows, so why is this difference?
Thank you in advance!
6 Answers, 1 is accepted
0
Stanislav
Top achievements
Rank 1
answered on 15 Jan 2013, 05:51 AM
Hello Andrei,
How many rows are displayed in the RadGridView? Because it looks like it returns the number of rendered and displayed rows. Try to execute .RefreshVisualTree() after you identify the control.
Kind Regards,
Stanislav Hordiyenko
How many rows are displayed in the RadGridView? Because it looks like it returns the number of rendered and displayed rows. Try to execute .RefreshVisualTree() after you identify the control.
Kind Regards,
Stanislav Hordiyenko
0
Andrei
Top achievements
Rank 2
answered on 15 Jan 2013, 06:29 AM
RadGridView radGridView1 = app.VisualTree.Find.ByAutomationId<
RadGridView
>("RadGridView1");
app.RefreshVisualTrees();
radGridView1.Refresh();
var rowsCount = radGridView1.Rows.Count;
"Because it looks like it returns the number of rendered and displayed rows" - ok, but how to identify total number of rows in this radGridView?
0
Hello Andrei,
Please check out these articles:
- RadGridView Total Rows Count
- RadGridView Scrolling (coded solution)
- RadGridView Scrolling (non coded)
Let me know if you need additional help.
Regards,
Boyan Boev
the Telerik team
The reason you are getting only the visible rows is because of the virtualization. This is a limitation of the Visual Tree contained in the Silverlight engine. Silverlight puts into the Visual Tree only the UI components necessary to render the page on the screen.
The easiest way to get the total rows count is by dividing the total height of the grid, visible plus non-visible by the height of the row.
Here is the code:
FrameworkElement virtualizingPanel = app.Find.ByType(
"GridViewVirtualizingPanel"
);
int
extentHeight;
// The total height of the grid, visible plus non-visible
int
rowHeight;
// Detect the extent height and the row height
extentHeight = (
int
)virtualizingPanel.GetProperty(
new
AutomationProperty(
"ExtentHeight"
,
typeof
(
int
)));
rowHeight = (
int
)radGridView1.GetProperty(
new
AutomationProperty(
"RowHeight"
,
typeof
(
int
)));
int
totalPageRows = 0;
totalPageRows = (extentHeight/rowHeight);
Please check out these articles:
- RadGridView Total Rows Count
- RadGridView Scrolling (coded solution)
- RadGridView Scrolling (non coded)
Let me know if you need additional help.
Regards,
Boyan Boev
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings
0
Andrei
Top achievements
Rank 2
answered on 17 Jan 2013, 09:55 AM
This works, thank you...
But now another problem: in this example (http://demos.telerik.com/silverlight/#GridView/Sorting) how to copy ALL [Company Name] in a List<string>()
I try to do this:
but the result not correspond with the reality, what I do wrong ?
But now another problem: in this example (http://demos.telerik.com/silverlight/#GridView/Sorting) how to copy ALL [Company Name] in a List<string>()
I try to do this:
Manager.LaunchNewBrowser(BrowserType.InternetExplorer, true);
ActiveBrowser.AutoWaitUntilReady = true;
ActiveBrowser.Window.SetActive();
ActiveBrowser.Window.SetFocus();
ActiveBrowser.Window.Maximize();
ActiveBrowser.NavigateTo(@"http://demos.telerik.com/silverlight/#GridView/Sorting");
// Get an instance of the running Silverlight Application.
app = ActiveBrowser.SilverlightApps()[0];
ActiveBrowser.RefreshDomTree();
// Get an instance of the running Silverlight Application.
app = ActiveBrowser.SilverlightApps()[0];
app.VisualTree.Find.Strategy = FindStrategy.AlwaysWaitForElementsVisible;
app.VisualTree.Find.WaitOnElementsTimeout = timeout;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
RadGridView radGridView1 = app.VisualTree.Find.ByAutomationId<
RadGridView
>("RadGridView1");
FrameworkElement virtualizingPanel = app.Find.ByType("GridViewVirtualizingPanel");
int radGridViewRowsCount = (int)virtualizingPanel.GetProperty(new AutomationProperty("ExtentHeight", typeof(int))) / (int)radGridView1.GetProperty(new AutomationProperty("RowHeight", typeof(int)));
List<
string
> cellsValues = new List<
string
>();
//select first row
radGridView1.Rows[0].User.Click();
//add visible rows to list
for (int index = 0; index <
radGridView1.Rows.Count
; index++)
{
//System.Diagnostics.Debug.WriteLine("before: " + radGridView.Rows[index].Cells[columnIndex].Value.ToString());
cellsValues.Add(radGridView1.Rows[index].Cells[1].Value != null ? radGridView1.Rows[index].Cells[1].Value.ToString() : "");
radGridView1.User.KeyPress(System.Windows.Forms.Keys.Down, 500);
}
int
virtualizingRowIndex
=
0
;
for (int
index
=
radGridView1
.Rows.Count; index < radGridViewRowsCount; index++)
{
cellsValues.Add(radGridView1.Rows[virtualizingRowIndex].Cells[1].Value != null ? radGridView1.Rows[virtualizingRowIndex].Cells[1].Value.ToString() : "");
radGridView1.User.KeyPress(System.Windows.Forms.Keys.Down, 500);
virtualizingRowIndex++;
if (virtualizingRowIndex >= radGridView1.Rows.Count)
{
virtualizingRowIndex = 0;
}
}
but the result not correspond with the reality, what I do wrong ?
0
Hi Andrei,
Boyan Boev
the Telerik team
Unfortunately this is a virtualization problem. You can't walk through the entire grid by its index. It is constantly changing.
To achieve this you need to implement your own logic for the indexing (e.g. some ID column) then base your logic for walking through the grid on this column for example.
Hope this helps.
Boyan Boev
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings
0
Andrei
Top achievements
Rank 2
answered on 22 Jan 2013, 12:51 PM
Ok, thank you. I'll try later to find some workarounds.