Multi column Rad Combo Filter Help

5 posts, 0 answers
  1. Prassin
    Prassin avatar
    87 posts
    Member since:
    Jun 2012

    Posted 25 Jul 2012 Link to this post

    Hi all,

    I have a Rad Combo and the combo having 2 text fields and 1 value field .. i wish to use filter option to this Rad combo.. filter option should work with that 2 text fields .. how can i achieve this.. either server side or client side.. 


    Regards,

    Prassin
  2. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 25 Jul 2012 Link to this post

    Hello Prassin,

    What exactly is your application scenario? Do you have item templates defined for RadComboBox?
    Could you please paste here the markup of RadComboBox that you use on your page?

    The following online example might be of help: http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/filteringcombo/defaultcs.aspx.

    Kind regards,
    Ivana
    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.
  3. Prassin
    Prassin avatar
    87 posts
    Member since:
    Jun 2012

    Posted 26 Jul 2012 Link to this post

    ASPX

    <telerik:RadComboBox runat="server" ID="RadCmbxEmployee" Height="190px" EmptyMessage="Select Employee Name"
                                                            Width="600px" MarkFirstMatch="true" DataSourceID="SqlDataSource4" EnableLoadOnDemand="true"
                                                            HighlightTemplatedItems="true"
                                                        OnClientItemsRequested="UpdateItemCountField" Filter="Contains"
                                                            OnDataBound="RadCmbxEmployee_DataBound" OnItemDataBound="RadCmbxEmployee_ItemDataBound"
                                                            OnItemsRequested="RadCmbxEmployee_ItemsRequested">
                                                            <HeaderTemplate>
                                                                <ul class="rcbHovered">
                                                                    <li class="dropDownCol">Name</li>
                                                                    <li class="col1">Code</li>                                                                   
                                                                </ul>
                                                            </HeaderTemplate>
                                                            <ItemTemplate>
                                                                <ul class="dropDown">
                                                                    <li class="dropDownCol">
                                                                        <%#DataBinder.Eval(Container.DataItem, "EmpName")%></li>
                                                                    <li class="col1">
                                                                        <%#DataBinder.Eval(Container.DataItem, "EmpCode")%></li>                                                                  
                                                                </ul>
                                                            </ItemTemplate>
                                                            <FooterTemplate>
                                                                A total of
                                                                <asp:Literal runat="server" ID="RadComboItemsCount" />
                                                                items
                                                            </FooterTemplate>
                                                        </telerik:RadComboBox
                                                    <asp:SqlDataSource ID="SqlDataSource4" runat="server"
                                                        ConnectionString="<%$ ConnectionStrings:AMSysConnectionString %>"
                                                         
                                                        SelectCommand="SELECT [EmpName], [EmpCode], [EmpId] FROM [EmployeeDetails] WHERE ([EmpStatus] = @EmpStatus)">
                                                        <SelectParameters>
                                                            <asp:Parameter DefaultValue="P" Name="EmpStatus" Type="String" />
                                                        </SelectParameters>
                                                    </asp:SqlDataSource>
                                                    <script type="text/javascript">
                                                        function UpdateItemCountField(sender, args) {
                                                            //set the footer text
                                                            sender.get_dropDownElement().lastChild.innerHTML = "A total of " + sender.get_items().get_count() + " items";
                                                        }
                                                        </script>


    Here EmpID i set as value field .. and EmpName and EmpCode i set as text fileds.. 

    Code behind
    Protected Sub RadCmbxEmployee_ItemDataBound(ByVal sender As Object, ByVal e As RadComboBoxItemEventArgs)
           e.Item.Text = (DirectCast(e.Item.DataItem, DataRowView))("EmpName").ToString()
           e.Item.Value = (DirectCast(e.Item.DataItem, DataRowView))("EmpId").ToString()
     End Sub
       Protected Sub RadCmbxEmployee_ItemsRequested(ByVal sender As Object, ByVal e As RadComboBoxItemsRequestedEventArgs)
           Dim sql As String = "SELECT * from EmployeeDetails WHERE EmpStatus='P' and EmpName LIKE '" + e.Text + "%'"
           SqlDataSource4.SelectCommand = sql
           RadCmbxEmployee.DataBind()
       End Sub

    i wish to use the filter option on that EmpCode column too.. that's my requirement..

    Please help..

    Regards,

    Prassin 
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 26 Jul 2012 Link to this post

    Hi Prassin,

    Try the following code snippet in the ItemsRequested event of RadComboBox.

    C#:
    Protected Sub RadCmbxEmployee_ItemsRequested(ByVal sender As Object, ByVal e As RadComboBoxItemsRequestedEventArgs)
           Dim sql As String = "SELECT * from EmployeeDetails WHERE EmpStatus='P' and EmpName LIKE '" + e.Text + "%' OR EmpCode LIKE'" + e.Text + "%'"
           SqlDataSource4.SelectCommand = sql
           RadCmbxEmployee.DataBind()
    End Sub

    Hope this helps.

    Regards,
    Princy.
  5. Prassin
    Prassin avatar
    87 posts
    Member since:
    Jun 2012

    Posted 26 Jul 2012 Link to this post

    Hi Princy,

    Thanks very much for this code.. its working ..


    Regards,

    Prassin
Back to Top