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

Combobox + Checkbox+Load on demand+search Item

1 Answer 87 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Murugesh
Top achievements
Rank 1
Murugesh asked on 18 Nov 2013, 08:26 PM

Hello Sir,

I have the following requirement  to be implemented on my web page. It is similar to MS Excel 2010 Filter. Attached is the sample.

1. Multiple selection from the Dropdown using checkbox option.
2. Have to use web service to load the data ( I have approx. 5000 Items )
3. Autosuggest, while typing system should show the item to be picked.

I Just purchased the new Telerik License . I hope it will support my requirements

Thank you

Regards,
Muru

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Nov 2013, 07:10 AM
Hi Murugesh,

Please have a look into the sample code i tried to achieve your scenario.

ASPX:
<telerik:RadComboBox runat="server" ID="RadComboBox1" Width="300px" EnableLoadOnDemand="true"
    CheckBoxes="true" OnClientItemsRequesting="OnClientItemsRequesting" Filter="StartsWith">
    <WebServiceSettings Method="GetProducts" Path="Products.asmx" />
</telerik:RadComboBox>

JavaScript:
<script type="text/javascript">
    function OnClientItemsRequesting(sender, eventArgs) {
        var context = eventArgs.get_context();
        context["FilterString"] = eventArgs.get_text();
    }
</script>

WebService CS Page(Products.CS):
[WebMethod]
public RadComboBoxItemData[] GetProducts(object context)
{
    IDictionary<string, object> contextDictionary = (IDictionary<string, object>)context;
    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
    string filterString = ((string)contextDictionary["FilterString"]).ToLower();
    SqlCommand selectCommand = new SqlCommand(
    @" SELECT * FROM Customers WHERE (CompanyName) LIKE '" + filterString + "%'", connection);
    SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);
    DataTable products = new DataTable();
    adapter.Fill(products);
    List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(products.Rows.Count);
    foreach (DataRow row in products.Rows)
    {
        RadComboBoxItemData itemData = new RadComboBoxItemData();
        itemData.Text = row["CompanyName"].ToString();
        itemData.Value = row["CompanyName"].ToString();
        result.Add(itemData);
    }
    return result.ToArray();
}


Thanks,
Shinu.
Tags
ComboBox
Asked by
Murugesh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or