RadGrid Batch Editing cannot change content

8 posts, 0 answers
  1. Catriona
    Catriona avatar
    13 posts
    Member since:
    Jul 2013

    Posted 09 Jan 2015 Link to this post

    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>
  2. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 14 Jan 2015 Link to this post

    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
     
  3. Catriona
    Catriona avatar
    13 posts
    Member since:
    Jul 2013

    Posted 26 Feb 2015 in reply to Ivaylo Link to this post

    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.
  4. Catriona
    Catriona avatar
    13 posts
    Member since:
    Jul 2013

    Posted 26 Feb 2015 in reply to Ivaylo Link to this post

    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.
  5. Catriona
    Catriona avatar
    13 posts
    Member since:
    Jul 2013

    Posted 26 Feb 2015 in reply to Catriona Link to this post

    The attachment which seems to be missing
  6. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 03 Mar 2015 Link to this post

    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
     
  7. Catriona
    Catriona avatar
    13 posts
    Member since:
    Jul 2013

    Posted 03 Mar 2015 in reply to Ivaylo Link to this post

    Alternative solution file provided.
  8. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 06 Mar 2015 Link to this post

    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
     
Back to Top