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

RadComboBox - Search Any Part Of String

3 Answers 149 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 16 Nov 2012, 10:35 PM
So, I have a RadComboBox that is populated with a product number and a name (123456 - product name).  I want to be able to type in either the product number ("123456") or the product name and have the auto complete functionality work.

I know I need to have a client side script "OnClientItemsRequesting"
I know I can probably use a [WebMethod] - probably using the <WebServiceSettings> within the Telerik RadComboBox....
I know that I need to populate the data from a database...
I know that I have to do this for 6 different combo boxes.

...but my knowledge and skill set is terrible after that.

I'm assuming that my client side script will be something like this:
function OnClientItemsRequesting(sender, eventArgs) {
     var context = eventArgs.get_context();
     context["FilterString"] = eventArgs.get_text();
 }

My web method should be something like this:
public RadComboBoxItemData[] GetItem1Values(object context)
        {
            //previously declared global
            DataBaseConnection db = new DataBaseConnection();
 
            IDictionary<string, object> contextDictionary = (IDictionary<string, object>)context;
 
            string filterString = ((string)contextDictionary["FilterString"]).ToLower();
            string filterNext = ((string)contextDictionary["FilterNext"]);
 
            BrandCode = cmbProd1Filter.SelectedItem.Value;
            DataTable dt = db.StoredProcedures.getItemBumbersByBrandCode_Command(QtyUp, BrandCode);
 
            var filterRows = (from dr in dt.AsEnumerable() select dr.Field<string>("ItemName")).ToArray();
 
          //I have no idea what happens after that... I need help
        }

Any help would be appreciated... I really need it.

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Mark
Top achievements
Rank 1
answered on 19 Nov 2012, 03:48 PM
Anything? Need some help, here....
0
Accepted
Cat Cheshire
Top achievements
Rank 1
answered on 20 Nov 2012, 01:14 PM
If you have the filterRows as an array - you can simply loop through this array and create a RadComboBoxItemData objects list to return.
In this article you can see similar approach:
http://www.telerik.com/help/aspnet-ajax/combobox-load-on-demand-webservice.html
0
Mark
Top achievements
Rank 1
answered on 20 Nov 2012, 02:03 PM
AH!  Thank you!  That's perfect!
Tags
ComboBox
Asked by
Mark
Top achievements
Rank 1
Answers by
Mark
Top achievements
Rank 1
Cat Cheshire
Top achievements
Rank 1
Share this question
or