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

Setting Tooltip on RadComboBoxItemData during load on demain WS call

3 Answers 110 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 24 Sep 2008, 03:05 PM
I have a RadComboBox that is setup for LoadOnDemand via a WS call.  How do I set the tooltip?  It doesnt look like the RadComboBoxItemData class does not expose this property.

Thanks,

3 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 24 Sep 2008, 04:28 PM
Hello Randy,

Indeed RadComboBoxItemData does not expose a ToolTip property. You can use the Attributes collection instead to return the ToolTip. Later in the OnClientItemsRequested event handler you can iterate through all Items in the Combo and set a ToolTip for their HTML elements.

[In the Web Service Web method]
itemData.Attributes["ToolTip"] = "some tooltip text"

[In OnClientItemsRequested event handler]
        function clientItemsRequested(sender, eventArgs) 
        { 
            var items = sender.get_items(); 
             
            for (var itemIndex = 0; itemIndex < items.get_count(); itemIndex++) 
            { 
                var item = items.getItem(itemIndex); 
                 
                item.get_element().title = item.get_attributes().getAttribute("ToolTip"); 
            } 
        } 

This should do the work.

All the best,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Bryan Brannon
Top achievements
Rank 2
answered on 11 Feb 2009, 06:45 PM
I want to do something very similar, attaching a style attribute to color the text based on some logic in the webservice;

If ... Then
   itemData.Attributes.Add("style", "color:green")
Else
   itemData.Attributes.Add("style", "color:red")
End If

This does not work using my method from the Webservice that returns RadComboBoxItemData.

Any help?
0
Bryan Brannon
Top achievements
Rank 2
answered on 11 Feb 2009, 06:54 PM
Sorry, with a bit of playing around I finally got it:

Webservice Method:
If ... Then
   itemData.Attributes.Add("Color", "green")
Else
   itemData.Attributes.Add("Color", "red")
End If

My RadComboBox.OnClientItemsRequested event:  (eval the custom attribute, color the items)
function ClientItemsRequested(sender, eventArgs) {  
    var items = sender.get_items();  
 
    for (var itemIndex = 0; itemIndex < items.get_count(); itemIndex++) {  
        var item = items.getItem(itemIndex);  
        item.get_element().style.color = item.get_attributes().getAttribute("Color");  
    }  

Tags
ComboBox
Asked by
Randy
Top achievements
Rank 1
Answers by
Simon
Telerik team
Bryan Brannon
Top achievements
Rank 2
Share this question
or