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

RadGrid Filtering using RadComboBox

5 Answers 161 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 Mar 2015, 03:20 PM
Using the Testing Framwework how do you cause a filter which is RadComboBox to select one of its items?
Can you provide sample code using your http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx
for example use the City combobox to select the Anchorage item.

I can find the combobox but when I attempt to click on my selected item no filtering is ocuring.
How to I associate the filter and combobox? I've tries clicking in the filter for the grid but that still doesn't apply the filter.

5 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 12 Mar 2015, 01:41 PM
Hello Catriona,

Please send us your test so we can help you with the code.

Thank you!

Regards,
Boyan Boev
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 13 Mar 2015, 10:25 AM
I'm trying to the same as your demo example. Here are a few more details.
I bind the data content using NeedDataSource. There are 53 entries in total.
The combobox has All, IO Input, IO Output. Trying to select IO Input to reduce the items to 30.
The ASPX:
<telerik:RadGrid ID="IOStatusGrid" runat="server" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" PageSize="15"
    OnNeedDataSource="IOStatusGrid_NeedDataSource"
    OnItemDataBound="IOStatusGrid_ItemDataBound" OnItemCommand="IOStatusGrid_ItemCommand">
    <PagerStyle PageSizeControlType="None" />
    <MasterTableView EditMode="InPlace" DataKeyNames="Id,StatusIndex,StatusName">
        <CommandItemSettings ShowAddNewRecordButton="False" />
         <Columns>
             <telerik:GridBoundColumn AllowFiltering="False" DataField="Id" DataType="System.Int32" Display="false" FilterControlAltText="Filter Id column" HeaderText="Id" ShowFilterIcon="False" UniqueName="Id">
                 <ColumnValidationSettings>
                     <ModelErrorMessage Text="" />
                 </ColumnValidationSettings>
             </telerik:GridBoundColumn>
             <telerik:GridBoundColumn DataField="StatusIndex" DataType="System.Int32" Display="False" FilterControlAltText="Filter StatusIndex column" UniqueName="StatusIndex">
                 <ColumnValidationSettings>
                     <ModelErrorMessage Text="" />
                 </ColumnValidationSettings>
             </telerik:GridBoundColumn>
             <telerik:GridBoundColumn DataField="IdType" FilterControlAltText="Filter IdType column" HeaderText="Type" ReadOnly="true" UniqueName="IdType">
                 <ColumnValidationSettings>
                     <ModelErrorMessage Text="" />
                 </ColumnValidationSettings>
                 <FilterTemplate>
                     <telerik:RadComboBox ID="IdTypeComboBox" runat="server" AutoPostBack="True" DataTextField="Id" OnPreRender="IdTypeComboBox_PreRender" OnSelectedIndexChanged="IdTypeComboBox_SelectedIndexChanged">
                         <Items>
                             <telerik:RadComboBoxItem runat="server" Text="All" Value="All" />
                             <telerik:RadComboBoxItem runat="server" Text="IO Input" Value="IO Input" />
                             <telerik:RadComboBoxItem runat="server" Text="IO Output" Value="IO Output" />
                         </Items>
                     </telerik:RadComboBox>
                 </FilterTemplate>
             </telerik:GridBoundColumn>
             <telerik:GridBoundColumn DataField="StatusName" FilterControlAltText="Filter StatusName column" HeaderText="Name" MaxLength="50" ReadOnly="true" UniqueName="StatusName">
                 <ColumnValidationSettings>
                     <ModelErrorMessage Text="" />
                 </ColumnValidationSettings>
             </telerik:GridBoundColumn>
             <telerik:GridBoundColumn UniqueName="StatusValue" DataField="StatusValue" Display="false" FilterControlAltText="Filter StatusValue column" HeaderText="Status Value" MaxLength="50" >
                 <ColumnValidationSettings>
                     <ModelErrorMessage Text="" />
                 </ColumnValidationSettings>
             </telerik:GridBoundColumn>
             <telerik:GridCheckBoxColumn UniqueName="StatusValueCheckBox" AllowFiltering="False" AllowSorting="False" DataType="System.Boolean" FilterControlAltText="Filter StatusValueCheckBox column"
                 HeaderText="Status" DataField="StatusValueBool">
                 <ItemStyle Height="20px" />
             </telerik:GridCheckBoxColumn>
             <telerik:GridBoundColumn DataField="UpdateDateTime" DataType="System.DateTime" FilterControlAltText="Filter UpdateDateTime column" HeaderText="Last Updated" ReadOnly="true" UniqueName="UpdateDateTime">
                 <ColumnValidationSettings>
                     <ModelErrorMessage Text="" />
                 </ColumnValidationSettings>
             </telerik:GridBoundColumn>
             <telerik:GridEditCommandColumn ButtonType="ImageButton" FilterControlAltText="Filter OutputEditCommand column" UniqueName="OutputEditCommand">
             </telerik:GridEditCommandColumn>
        </Columns>
        <PagerStyle PageSizeControlType="None" />
    </MasterTableView>
</telerik:RadGrid>



The Test:
protected const string IOSTATUS_GRID = "ctl00_ContentPlaceHolder1_ctl00_IOStatusGrid";
protected const string IOSTATUS_TYPE_COMBOBOX = IOSTATUS_GRID + "_ctl00_ctl02_ctl02_IdTypeComboBox";

[Test]
        public void TestTypeFilter()
        {
            ActiveBrowser.NavigateTo(IO_STATUS_PAGE);
            Assert.AreEqual(IO_STATUS_PAGE_TITLE, ActiveBrowser.PageTitle, "Actual page title = \"{0}\"", ActiveBrowser.PageTitle);
 
            //locate TypeFilter & select IOInput (30 in 2 pages)
            RadGrid ioGrid = Find.ById<RadGrid>(IOSTATUS_GRID);
            GridFilterItem filterItem = ioGrid.GridFilterItem;
            filterItem.Click();
 
            RadComboBox typeCombo = Find.ById<RadComboBox>(IOSTATUS_TYPE_COMBOBOX);
            typeCombo.ShowDropDown();
 
            RadComboBoxItem all = typeCombo.FindItemByText("All");
            RadComboBoxItem ioInput = typeCombo.FindItemByText("IO Input");
            RadComboBoxItem ioOutput = typeCombo.FindItemByText("IO Output");
 
            Assert.AreEqual(0, all.Index);
            Assert.AreEqual(1, ioInput.Index);
            Assert.AreEqual(2, ioOutput.Index);
 
            //Try V1
            //ioInput.Click();
            //filterItem.Click();
            //// Assert the Grid is filtered
            //Wait.For<GridTableView>(masterTable => masterTable.PageCount == 2, ioGrid.MasterTable, 8000);
 
            //Try V2
            //typeCombo.SelectItemByText("IO Input");
            //Wait.For<RadComboBox>(combo => combo.SelectedIndex == 1, typeCombo, 5000);
 
            //Try V3
            ioInput.Select();
            Wait.For<RadComboBox>(myCombo => myCombo.SelectedIndex == 1, typeCombo, 10000);
 
            GridPager pager = ioGrid.Pager;
            Assert.IsTrue(pager.InfoText.Contains("30 items in 2 pages"), "Actual value is " + pager.InfoText);
 
            //WIP
        }






0
Boyan Boev
Telerik team
answered on 18 Mar 2015, 09:20 AM
Hello Catriona,

Are you able to find the ComBox at all?

If so could you please to use this code: 

ioInput.MouseClick();

If the issue persists please describe what exactly you want to select and click on our demo site and I will prepare a sample code for that.

Hope to hear from you soon.

Regards,
Boyan Boev
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 19 Mar 2015, 03:44 PM
This made no difference. The Combo box item is still not selected.
Yes I can see the combobox because I can check that there are three combo items and they have the correct text.
What I cannot do is select one of them.

Using the demo code http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx
I want to select one of the contact titles, say "Accounting Manager" and see that the filter has been applied.

This is the test that I am attempting to write. Your demo code is similar in that it has a RadGrid in a Master page.
My code has the grid inside a UserControl.

Thanks,
Catriona Potter
0
Boyan Boev
Telerik team
answered on 24 Mar 2015, 09:05 AM
Hello Catriona,

Here is a code example which selects "Accounting Manager" from the filter drop down:

RadGrid myGrid = ActiveBrowser.Find.ById<RadGrid>("ctl00_ContentPlaceholder1_RadGrid1");

HtmlTable filterTable = myGrid.Find.ById<HtmlTable>("ctl00_ContentPlaceholder1_RadGrid1_ctl00");

HtmlTableRow filter = filterTable.Find.ByAttributes<HtmlTableRow>("class=rgFilterRow");

Telerik.WebAii.Controls.Html.RadComboBox filterComboBox = filter.Find.ById<Telerik.WebAii.Controls.Html.RadComboBox>("ctl00_ContentPlaceholder1_RadGrid1_ctl00_ctl02_ctl02_RadComboBoxTitle");

filterComboBox.ToggleDropDown();

filterComboBox.SelectItemByText("Accounting Manager");

//System.Threading.Thread.Sleep(5000);

Let me know if this helps.

Regards,
Boyan Boev
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
Boyan Boev
Telerik team
Catriona
Top achievements
Rank 1
Share this question
or