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

add a new row to RadGridView

1 Answer 64 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Manjit
Top achievements
Rank 1
Manjit asked on 02 Aug 2012, 01:00 AM
Hi, I want to add a new row to a RadGridView via automation. I've searched the forums but haven't found this topic yet.
I see that there is a NewRow property, in my case..
Pages.USSPOSCOIndustries.FrameHome.SilverlightApp.GridviewEarnings.NewRow

There is also a function called AddNewRow which I assume is used to make the new row.
So I'm guessing I have to set each column in my NewRow then call AddNewRow to commit it. But I don't know how to loop through each column in my row to set each columns value.
So far I have...

Telerik.WebAii.Controls.Xaml.RadGridView rgv = Pages.USSPOSCOIndustries.FrameHome.SilverlightApp.GridviewEarnings;
int rowCounter = rgv.Rows.Count;
int cellCounter = 1; 
 
foreach(Telerik.WebAii.Controls.Xaml.GridViewCell gCell in Pages.USSPOSCOIndustries.FrameHome.SilverlightApp.GridviewEarnings.NewRow) { //Nested loop; Goes through all the cells within each row
           
     if (gCell.XamlTag == "textbox" && gCell.AutomationId == "PART_EditableTextBox")
        gCell.Text = (string)(System.Convert.ChangeType(Data["Hours"], typeof(string)));
        //You can implement any type of verification you like against the text here
 
     if (gCell.XamlTag == "selectivescrollinggrid" && gCell.Name == "grid")
        gCell.Text = (string)(System.Convert.ChangeType(Data["Hours"], typeof(string)));
        //You can implement any type of verification you like against the text here
 
        cellCounter++;
    }
    rowCounter++;

     Pages.USSPOSCOIndustries.FrameHome.SilverlightApp.GridviewEarnings.AddNewRow();

Is this correct? Also, I would like to search by xamlpath as well as xamlTag for a column's textbox, dropdown, etc. Is this possible?

Thanks for the help

1 Answer, 1 is accepted

Sort by
0
Accepted
Cody
Telerik team
answered on 07 Aug 2012, 03:34 AM
Hello,

To go along with my response to your support ticket on the same question, here's code I got working on this sample page:

RadGridView grid = ActiveBrowser.SilverlightApps()[0].Find.ByAutomationId<RadGridView>("RadGridView1");
 
grid.Rows[0].Cells[0].User.Click();
Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Insert);
 
Manager.Desktop.KeyBoard.TypeText("79");
Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab);
Manager.Desktop.KeyBoard.TypeText("New Product Name");
Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab);
Manager.Desktop.KeyBoard.TypeText("14.35");
Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Tab);
Manager.Desktop.KeyBoard.TypeText("42");
Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter);
Kind regards,
Cody
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Manjit
Top achievements
Rank 1
Answers by
Cody
Telerik team
Share this question
or