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

Multi column Rad Combo Filter Help

4 Answers 80 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Prassin
Top achievements
Rank 1
Prassin asked on 25 Jul 2012, 12:17 PM
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

4 Answers, 1 is accepted

Sort by
0
Ivana
Telerik team
answered on 25 Jul 2012, 03:23 PM
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.
0
Prassin
Top achievements
Rank 1
answered on 26 Jul 2012, 05:05 AM
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 
0
Princy
Top achievements
Rank 2
answered on 26 Jul 2012, 06:34 AM
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.
0
Prassin
Top achievements
Rank 1
answered on 26 Jul 2012, 06:50 AM
Hi Princy,

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


Regards,

Prassin
Tags
ComboBox
Asked by
Prassin
Top achievements
Rank 1
Answers by
Ivana
Telerik team
Prassin
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or