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

RadComboBox in FilterTemplate in Details Table Error

1 Answer 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
john81
Top achievements
Rank 1
john81 asked on 19 Mar 2014, 12:49 PM
I have a RadGrid with a Details Table that is using a RadComboBox in the FilterTemplate.  The RadComboBox get populated correctly and it works correctly filtering one Details Table.  

<telerik:GridTemplateColumn HeaderText="State" SortExpression="State_cd" UniqueName="State_cd" ShowFilterIcon="True"
     DataField="State_cd" CurrentFilterFunction="EqualTo" AutoPostBackOnFilter="True" >
    <ItemTemplate>
        <asp:Label runat="server" ID="lblState" Text='<%# Eval("State_cd") %>'></asp:Label>
    </ItemTemplate>
 
    <FilterTemplate>
        <telerik:RadComboBox runat="server" ID="rcbState" DataTextField="State_cd" DataValueField="State_cd" AppendDataBoundItems="true"
            RenderingMode="Simple" EnableEmbeddedSkins="False" Skin="2015"
            SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("State_cd").CurrentFilterValue %>'
            OnClientSelectedIndexChanged="State_Changed" OnInit="rcbState_Init">
            <Items>
                <telerik:RadComboBoxItem Text="All" />
            </Items>
        </telerik:RadComboBox>
        <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
            <script type="text/javascript">
                function State_Changed(sender, args) {
                    var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                    var strState = args.get_item().get_value();
                    tableView.filter("State_cd", strState, "EqualTo");
                }
            </script>
        </telerik:RadScriptBlock>
    </FilterTemplate>                   
</telerik:GridTemplateColumn>
 

But as soon as I set that one filter and go to expand a different Details Table, I'm getting an error.

Selection out of range
Parameter name: value Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Selection out of range
Parameter name: value

I'm going to guess that is because I am attempting to populate the RadComboBox uniquely for each Details Table so that it only contains values in the data source for that Details Table.  Is what I'm trying to achieve possible?  Or does the datasource for the RadComboBox  filter need to be the same in all the Details Tables.

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 24 Mar 2014, 09:48 AM
Hi John,

This problem is probably related to the following line:
<telerik:RadComboBox ...
 SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("State_cd").CurrentFilterValue %>'>

Can you please remove the aforementioned property and select the combo item on the code-behind according to your specific scenario. For instance, you can use something like this:
protected void RadComboBoxCountry_DataBound(object sender, EventArgs e)
{
    RadComboBox combo = sender as RadComboBox;
    GridFilteringItem container = combo.NamingContainer as GridFilteringItem;
    string value = container.OwnerTableView.GetColumn("ShipCountry").CurrentFilterValue;
 
    if (!string.IsNullOrEmpty(value))
    {
        RadComboBoxItem item = combo.FindItemByValue(value);
        if (item == null)
        {
            item = new RadComboBoxItem(value, value) { Selected = true };
            combo.Items.Add(item);
        }
        item.Selected = true;
    }
}

Hope this helps.

Regards,
Eyup
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
Grid
Asked by
john81
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or