RadComboBoxItemData on Client Side

4 posts, 0 answers
  1. Yash
    Yash avatar
    27 posts
    Member since:
    Sep 2010

    Posted 19 May 2011 Link to this post

    Hi,
    I am using a List of "RadComboBoxItemData" objects to load data into RadComboBox using the LoadOnDemand functionality. My Question is,
    I have set few attributes on the server side and I want to access them on the client side. let me know how to do that.

    For example:
    ServerSide(Web Service):
    List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems);
    foreach(row in rows)
    {
    RadComboBoxItemData itemData = new RadComboBoxItemData();
    itemData.Attributes.Add("HostName", row["HostName"].ToString());
    itemData.Value = row["ID"].ToString();
    result.Add(itemData);
    }
    return result;

    ClientSide:
    function onItemDataBound(sender, eventArgs) {//the combo item
     var item = eventArgs.get_item();
    var dataItem = eventArgs.get_dataItem();
    ............AND THEN................??

    Any Help will be appreciated. Secondly, I want to implement CheckBoxes so that I can add Multi-Select Functionality to it. Please suggest me a work around on this one.

    Thanks in Advance. Appreciate your help.
  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 25 May 2011 Link to this post

    Hello Yash,

    In order to obtain the RadComboBox item attribute on client-side you can handle OnClientItemsRequested or OnClientSelectedIndexChanged event in this way:
    <script type="text/javascript">
     
        function OnClientItemsRequested(sender, eventArgs) {
          var  items = sender.get_items();
          for (i = 0; i < items.get_count(); i++) {
          
                alert(items.getItem(i).get_attributes().getAttribute("test"));
            }
        }
         
        function ItemChanged(combo, eventArgs) {
            var item = eventArgs.get_item();
            alert(item.get_attributes().getAttribute("test"));
     
        }
    </script>

    <telerik:RadComboBox ID="RadComboBox1" runat="server"
    OnClientItemsRequested="OnClientItemsRequested"
    OnClientSelectedIndexChanged="ItemChanged"

    Please find more details about RadComboBox client-side events at this help article.
    More about Attributes collection you can find here.

    Regarding the scenario with the checkboxes that you describe - I can suggest you take a look at the first RadComboBox (“Type”) in this online demo.

    All the best,
    Kalina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. Yash
    Yash avatar
    27 posts
    Member since:
    Sep 2010

    Posted 25 May 2011 Link to this post

    Hi Kalina, thanks for the reply. However, my second question might not be that clear. Let me re-phrase that for you.
    I want to implement multi-select feature of RadComboBox when it is linked to a webservice. I know how to do it in general.

    regards
    Yash
  4. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 26 May 2011 Link to this post

    Hello Yash,

    I am afraid that the server-side Templates are not supported when you use a web service to populate RadComboBox with data.
    However you can use both LoadOnDemand and Templates at the same time - please take a look at this example.

    All the best,
    Kalina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top