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

Try to get RadComboBox value & text

3 Answers 405 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Fonny
Top achievements
Rank 1
Fonny asked on 04 Feb 2008, 06:28 PM

When I run the code, it displays item.value = Undefined and item.text = Undefined.
How do I get the value and text from radcombobox?

<
script type="text/javascript">

function

templateimageselected(item) {

alert(item.value +

" " + item.text);

}

</script>

<

telerik:RadComboBox id="rcbTemplateImg" runat="server"

Width="100px" Height="115px"

Skin="Vista" DataValueField="TemplateID" DataTextField="TemplateName"

MarkFirstMatch="false" HighlightTemplatedItems="True"

ShowToggleImage="True" AllowCustomText="false"

EnableLoadOnDemand="True"

OnClientSelectedIndexChanging="templateimageselected">

<ItemTemplate>

<table style="width: 375px" class="comboTable" cellspacing="0" cellpadding="0">

<tr>

<td style="width: 125px;" class="comboItemCell">

<div class="comboItem">

<img src='<%# DataBinder.Eval(Container.DataItem, "ThumbnailPath")%>' alt='<%# DataBinder.Eval(Container.DataItem, "TemplateName")%>'/>

<%

# DataBinder.Eval(Container.DataItem, "TemplateName")%>

</div>

</td>

</tr>

</table>

</ItemTemplate>

<CollapseAnimation Duration="200" Type="OutQuint" />

<ExpandAnimation Type="OutQuart" />

</telerik:RadComboBox>

3 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 05 Feb 2008, 08:01 AM
Hello Fonny,

Please find below your modified JS function that works as expected.

<script type="text/javascript">  
function templateimageselected(item)  
{  
    alert(item.get_value() + " " + item.get_text());  
}  
</script> 

For details on the matter please refer to the control's documentation under section The RadComboBoxItem client object model.

Regards,
Paul
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jason Maronge
Top achievements
Rank 1
answered on 05 Feb 2008, 08:20 PM
Paul, 

  The prometheus version should be


function templateimageselected(sender, eventArgs)     
{     
    alert(eventArgs.get_item().get_value() + " " + eventArgs.get_item().get_text());     
}    

shouldn't.  I really like the new JS API since most if not all the controls like the same.

Jason
0
Nikolay
Telerik team
answered on 07 Feb 2008, 11:07 AM
Hello Jason Maronge,

Yes, your syntax is correct.

Kind regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox
Asked by
Fonny
Top achievements
Rank 1
Answers by
Paul
Telerik team
Jason Maronge
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or