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

RadComboBoxItemData on Client Side

3 Answers 212 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Yash
Top achievements
Rank 1
Yash asked on 19 May 2011, 06:40 PM
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.

3 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 25 May 2011, 09:58 AM
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.

0
Yash
Top achievements
Rank 1
answered on 25 May 2011, 03:18 PM
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
0
Kalina
Telerik team
answered on 26 May 2011, 10:22 AM
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.

Tags
ComboBox
Asked by
Yash
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Yash
Top achievements
Rank 1
Share this question
or