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

RadGrid Batch Editing cannot change content

7 Answers 123 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Catriona
Top achievements
Rank 1
Catriona asked on 09 Jan 2015, 12:38 PM
I have a RadGrid which is always 5 rows of data.
I want to edit each cell. I accept the changes when the whole page is saved.
I want a test script to to test the Save Button so I need to edit the radgrid contents. I have taken my code from your sample in the forum
My test code is  (Note macros to find the elements/cells):
The line "HtmlInputText inputBox = cellToEdit.Find.ByTagIndex<HtmlInputText>("input", 0);" returns a null value.

How do I get hold of the cell details so that I can edit the vale?

private void ChangeLocationDetails()
{
    RadGrid bumpGrid = Find.ById<RadGrid>(BUMP_LOCATION_GRID);
    GridTableView masterTable = bumpGrid.MasterTable;
 
    int[] cellList = { BUMP_LOCATION_XPOSITION_CELL, BUMP_LOCATION_YPOSITION_CELL, BUMP_LOCATION_BZ_CELL, BUMP_LOCATION_FIELD_OF_VIEW_CELL, BUMP_LOCATION_PHI_CELL, BUMP_LOCATION_THETA_CELL };
    for (int i = 0; i < masterTable.DataItems.Count; i++)
    {
        float seed = 0.01F;
        foreach (int j in cellList)
        {
            HtmlTableRow rowToEdit = bumpGrid.MasterTable.Rows[i];
 
            // Locate the cell to be updated
            HtmlTableCell cellToEdit = bumpGrid.MasterTable.Rows[i].Cells[j];
            // Put the cell in edit mode by a mouse click
            cellToEdit.MouseClick(MouseClickType.LeftDoubleClick);
 
            m_Logger.Debug("TestBasicSetupRecipe:ChangeLocationDetails:bumpGrid.MasterTable.EditedItems.Count=" + bumpGrid.MasterTable.EditedItems.Count.ToString());
 
            // Locate the <input> element that is added when the cell enters edit mode
            HtmlInputText inputBox = cellToEdit.Find.ByTagIndex<HtmlInputText>("input", 0); //<== This returns NULL
 
            // Give it a new value
            Actions.SetText(inputBox, (i + seed).ToString());
 
            seed += 0.1F;
        }
    }
 
}

              
<telerik:RadGrid ID="BumpLocationGrid" runat="server" AutoGenerateColumns="False" AllowAutomaticUpdates="True" OnBatchEditCommand="BumpLocationGrid_BatchEditCommand">
    <MasterTableView AutoGenerateColumns="False" EditMode="Batch" BatchEditingSettings-EditType="Row" BatchEditingSettings-OpenEditingEvent="Click" >
        <CommandItemSettings ShowAddNewRecordButton="False" />
        <RowIndicatorColumn Visible="False">
        </RowIndicatorColumn>
        <Columns>
            <telerik:GridNumericColumn DecimalDigits="0" HeaderText="Index" UniqueName="GUIIndex" DataField="GUIIndex" DataType="System.Int32" Visible="false">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridNumericColumn>
            <telerik:GridNumericColumn DecimalDigits="2" FilterControlAltText="Filter XPosition column" HeaderText="X Position (mm)" UniqueName="XPosition" DataField="x_coord" DataType="System.Double">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridNumericColumn>
            <telerik:GridNumericColumn DecimalDigits="2" FilterControlAltText="Filter YPosition column" HeaderText="Y Position (mm)" UniqueName="YPosition" DataField="y_coord" DataType="System.Double">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridNumericColumn>
            <telerik:GridNumericColumn DecimalDigits="2" FilterControlAltText="Filter Bz column" HeaderText="Bz" UniqueName="Bz" DataField="bz" DataType="System.Double">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridNumericColumn>
            <telerik:GridNumericColumn DecimalDigits="3" FilterControlAltText="Filter FOV column" HeaderText="Field Of View" UniqueName="FOV" DataField="field_of_view" DataType="System.Double">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridNumericColumn>
            <telerik:GridNumericColumn DecimalDigits="2" FilterControlAltText="Filter Phi column" HeaderText="Phi" UniqueName="Phi" DataField="phi" DataType="System.Double">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridNumericColumn>
            <telerik:GridNumericColumn DecimalDigits="2" FilterControlAltText="Filter Theta column" HeaderText="Theta" UniqueName="Theta" DataField="theta" DataType="System.Double">
                <ColumnValidationSettings>
                    <ModelErrorMessage Text="" />
                </ColumnValidationSettings>
            </telerik:GridNumericColumn>
        </Columns>
 
        <BatchEditingSettings EditType="Row"></BatchEditingSettings>
    </MasterTableView>
</telerik:RadGrid>

7 Answers, 1 is accepted

Sort by
0
Ivaylo
Telerik team
answered on 14 Jan 2015, 12:17 PM
Hello Catriona,

Looking at the code provided I cannot determine why you are getting this behavior. One way to proceed is to refresh the DOM Tree after the double click using the code below and see if the input will be found.

Manager.ActiveBrowser.RefreshDomTree();

If this does not help, we will need to have access to the grid with a sample test so we can take a look.

Regards,
Ivaylo
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Catriona
Top achievements
Rank 1
answered on 26 Feb 2015, 01:43 PM
As the ticket associated with this has been closed I will post a sample project here.
This sample uses IISExpress
It automatically starts IIS using WebTestBase:StartIISExpress
    It uses the applicationhost.config supplied with solution.
    Sometimes the test needs to be run twice before IIS starts up correctly.

This sample uses NUNIT.The
Test TestSaveRecipeButton is the test that attempts to edit the RadGrid in Batch mode
    This test has worked but not consistently.
0
Catriona
Top achievements
Rank 1
answered on 26 Feb 2015, 01:44 PM
As the ticket associated with this has been closed I will post a sample project here.
This sample uses IISExpress
It automatically starts IIS using WebTestBase:StartIISExpress
    It uses the applicationhost.config supplied with solution.
    Sometimes the test needs to be run twice before IIS starts up correctly.

This sample uses NUNIT.
The Test TestSaveRecipeButton is the test that attempts to edit the RadGrid in Batch mode
    This test has worked but not consistently.
0
Catriona
Top achievements
Rank 1
answered on 26 Feb 2015, 01:46 PM
The attachment which seems to be missing
0
Ivaylo
Telerik team
answered on 03 Mar 2015, 08:57 AM
Hello Catriona,

With the project provided I am getting multiple compile errors, please provide a working solution out of the box so I can directly hit the problem you are experiencing.

Looking forward to hearing from you.

Regards,
Ivaylo
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Catriona
Top achievements
Rank 1
answered on 03 Mar 2015, 01:51 PM
Alternative solution file provided.
0
Ivaylo
Telerik team
answered on 06 Mar 2015, 11:09 AM
Hеllo Catriona,

Since I have some errors and problems running the project.

I'll be working on this and will update this thread as soon as I have more details.

Regards,
Ivaylo
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Catriona
Top achievements
Rank 1
Answers by
Ivaylo
Telerik team
Catriona
Top achievements
Rank 1
Share this question
or