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

Combobox Filter: Value 'All' missing

3 Answers 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marcus
Top achievements
Rank 1
Marcus asked on 12 Dec 2011, 12:02 PM
Hello All,

my filter is combobox: template with 2 columns instead of value 'All' is empty (see Attachment). It works correctly.
how can I get value 'All' on the top.

<telerik:GridTemplateColumn DataField="Type"
            FilterControlAltText="Filter TypeName column" HeaderText="<%$Resources:Texte, Type%>"
            SortExpression="Type" UniqueName="Type">
           <ItemTemplate>
              <asp:Label ID="Label1" runat="server" ToolTip='<%#Bind("TypeName")%>' Text='<%# Bind("Type") %>'></asp:Label>
           </ItemTemplate>
 
            <FilterTemplate>
                <telerik:RadComboBox ID="RadComboBoxCode" DataSourceID="SqlDataSource2" DataTextField="Code" Width="100px"
                    DataValueField="Code" Height="100px" AppendDataBoundItems="true" SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("Type").CurrentFilterValue %>'
                    runat="server" OnClientSelectedIndexChanged="TypeIndexChanged" DropDownWidth="350px">
                    <Items>
                        <telerik:RadComboBoxItem Text="All"/>
                    </Items>
                    <ItemTemplate>
                        <table style="width: 300px" cellspacing="0" cellpadding="0">
                            <tr>
                                <td style="width: 80px;">
                                        <%# Eval("Code")%>
                                </td>
                                <td style="width: 200px;">
                                    <%# Eval("CName")%>
                                </td>
                            </tr>
                        </table>
                    </ItemTemplate>
                </telerik:RadComboBox>
                <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
 
                    <script type="text/javascript">
                        function TypeIndexChanged(sender, args) {
                            var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
                            tableView.filter("Type", args.get_item().get_value(), "EqualTo");
                        }
                    </script>
 
                </telerik:RadScriptBlock>
            </FilterTemplate>
        </telerik:GridTemplateColumn>

3 Answers, 1 is accepted

Sort by
0
Marcus
Top achievements
Rank 1
answered on 14 Dec 2011, 03:21 PM
up
0
Tsvetina
Telerik team
answered on 15 Dec 2011, 09:02 AM
Hi Marcus,

This is so because you have an ItemTemplate which is not designed to take the values of static items. So, my suggestion is to modify your combo declaration like this:
<telerik:RadComboBox ID="RadComboBoxCode" DataSourceID="SqlDataSource2" DataTextField="Code"
    Width="100px" DataValueField="Code" Height="100px" AppendDataBoundItems="True"
    runat="server" DropDownWidth="350px">
    <Items>
        <telerik:RadComboBoxItem Text="All" />
    </Items>
    <ItemTemplate>
        <table style="width: 300px" cellspacing="0" cellpadding="0">
            <tr>
                <td style="width: 80px;">
                    <%# DataBinder.Eval(Container, "Text") %>
                </td>
                <td style="width: 200px;">
                    <%#DataBinder.Eval(Container, "Value")%>
                </td>
            </tr>
        </table>
    </ItemTemplate>
</telerik:RadComboBox>

If the item still does not show a value, find the combo on ItemDataBound event of RadGrid and explicitly bind the first item:
combo.Items[0].DataBind();

I hope this helps.

All the best,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Marcus
Top achievements
Rank 1
answered on 23 Dec 2011, 03:42 PM
Thanks Tsvetina.
Tags
Grid
Asked by
Marcus
Top achievements
Rank 1
Answers by
Marcus
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or