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

Radcombobx Problem

2 Answers 75 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Manish
Top achievements
Rank 1
Manish asked on 19 Nov 2010, 02:16 PM
Hi Team Telerik,

I am Using RadCombobx as a filter under the Rad Grid. Herein i am populating the data by using the Web service., now I want to add alternate colors to the each item inside the rad combo box. But I am not getting it on any of the Client Side event specially i tried on Client-Load event. but not succeeded yet.

Please can you quote something on this.

Also I want to know is there any other method for multiselection of radcombobox  other than Checkbox Method.

Thanking you in anticipation,
Fast response is highly appreciable.

With Regards,
Manish

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Nov 2010, 06:42 AM
Hello Manish,
You can use the following Javascript to set different colors to the ComboBox items.

JavaScript:
function OnClientLoad(sender, args)
     {
        var combo = sender;
        items = combo.get_items();
        for (i = 0; i < items.get_count(); i++)
        {
            var comboItem = items.getItem(i);
            if (i % 2 == 0)
            {
                comboItem._element.style.color = "green";
            }
            else
                comboItem._element.style.color = "Red";
         }
      }

You can make use of the property AutoCompleteSeparator to achieve your second requirement.Please go through the following document for more information.
ComboBox / Autocomplete
-Shinu.
0
Manish
Top achievements
Rank 1
answered on 20 Nov 2010, 10:36 AM
Hi Shinu,

Thanks for the fast response.

    But this trick not solve my problem yet. It reflect changes, if I used am previously filling radcombobx but in case of the "Autocomplete" feature It is not changing the the background color as well as font color.  

In autocomplete thing I am using Web-Service. Where in I am filling the data in the combobox by using RadComboBoxData to return the results

This is code where i am getting data from
I need to make alternate colors to the items


 [System.Web.Services.WebMethod]
    public RadComboBoxData GetName(RadComboBoxContext context)
    {
        try
        {
            int ItemsPerRequest = 10;

            DataSet ds = new DataSet();
            string parameter;
            parameter = context.Text + "%";
         
            string sql = "SELECT DISTINCT(BillToFirstName + ', ' + BillToLastName) as Name FROM ac_Orders Where ((BillToFirstName + ', ' + BillToLastName) like '" + parameter + "')  AND OrderStatusId <>7";
            SqlDataAdapter da = new SqlDataAdapter(sql, ConnString);
         
            da.Fill(ds, "ac_Orders");

            RadComboBoxData comboData = new RadComboBoxData();
            int itemOffset = context.NumberOfItems;
            int endOffset = Math.Min(itemOffset + ItemsPerRequest, ds.Tables[0].Rows.Count);
            comboData.EndOfItems = endOffset == ds.Tables[0].Rows.Count;

            List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(endOffset - itemOffset);

            for (int i = itemOffset; i < endOffset; i++)
            {
                RadComboBoxItemData itemData = new RadComboBoxItemData();
                itemData.Text = ds.Tables[0].Rows[i]["Name"].ToString();
                itemData.Value = ds.Tables[0].Rows[i]["Name"].ToString();

                result.Add(itemData);
            }

            comboData.Items = result.ToArray();
            return comboData;
        }
        catch (Exception ex)
        {
            throw;
        }
    }


Tags
ComboBox
Asked by
Manish
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Manish
Top achievements
Rank 1
Share this question
or