Hello,
I have a JS fuction that uses the $find function to try and get the selectedItemValue from a radCombobox, but the call returns nothing. Below is the beginning of the function. If I look at the combo var afer the '$find' call it is null
JS Function:
function getCounterFormat() {
debugger
var combo = $find("<%= DisplayCounter1.cboFormat.ClientID %>");
var formatString;
try{
formatString = combo.get_value;
( remainder removed for brevity )
When rendered the line looks like:
var combo = $find("ctl00_contentRight_DisplayCounter1_cboFormat")
in the rendered source this is the combobox id:
<div class="ComboBox_Default" id="ctl00_contentRight_DisplayCounter1_cboFormat"
the getCounterFormat() function is called on OnClientSelectedIndexChanged
Just to test I created a different function:
function setCounterFormat(obj) {
debugger
var formatString = obj.Value;
var newString = getCounterFormat();
This one does return the selecteditem value on the obj.Value call but the getCounterFormat() still returns nothing.
Can you tell me what I am doing wrong?
15 Answers, 1 is accepted
First, I suggest you replace the following line: formatString = combo.get_value; with formatString = combo.get_value();
Then you can check when you call the getCounterFormat method. You can use the pageLoad function where $find is guaranteed to return valid object:
function pageLoad()
{
var newString = getCounterFormat();
}
Regards,
Rosi
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

In this case modifying the code
formatString = combo.get_value;
to
formatString = combo.get_value();
I suggest you try this and let us known how this goes.
Regards,
Rosi
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

so combo.getvalue() returns undefined.
Is $find colliding with something? I also use YUI on this page.
What is the fully qualified name for $find?

You can also use the Telerik.Web.UI.RadComboBox.ComboBoxes array to access the combobox instances.
For example var combo1= Telerik.Web.UI.RadComboBox.ComboBoxes[0] will return the first combobox and
var combo2= Telerik.Web.UI.RadComboBox.ComboBoxes[1] will return the second combobox and so on.
For more details you can read our help article - Finding combobox on the client-side when it is embedded in another control
Kind regards,
Rosi
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.


thx for any help.
thx,
gabe
function RestrictedBeginDateTime_DateSelected(sender, args) { |
var dateTime = args.NewDate; |
var jqEndPicker = $('.rdtpEnd :first:input'); |
var id = jqEndPicker.attr('id'); // this is the ClientID |
var radEndPicker = $find(id); // this return null |
radEndPicker.set_minDate(dateTime); // this fails of course because radEndPicker is null |
} |


function RestrictedBeginDateTime_DateSelected(sender, args) { |
var dateTime = args.NewDate; |
var jqEndPicker = $('.rdtpEnd :first:input'); |
var id = jqEndPicker.attr('id'); // gets the ClientID (identical w/ what the VS08 debugger tells me) |
var radEndPicker = $find(id); // currently, always returns null |
if (!radEndPicker) { |
radEndPicker = window[id]; // gets the Rad object |
} |
radEndPicker.SetMinDate(dateTime); |
} |
This is my workaround for now until I can get these Rad objects to be registered w/ the Sys.Application._component object automatically.
thx,
gabe
P.S.
I am using external javascript files, and i have never been able to get <%= control.ClientID %> to work in external files.


thanks for the tip on initializing the ClientIDs! 8o)
I don't think that it's a timing issue because this is a client event that gets fired when the user has selected a date/time in a DateTimePicker. The page should be way past loading by this time i would think. I'll try the pageLoad though.
thx,
gabe


I have a specific requirement with RadComboBox. I have implemented it with asp dropdownlist, but I am not able to do it with RadComboBox...The requirement is whenever the selected value for any of the dropdown is "others", I need to make one textbox visible, which is just next to the dropdown.
html part
<
asp:DropDownList ID="ddlTitle" runat="server">
</
asp:DropDownList>
<
asp:TextBox ID="txtTitleOthers" runat="server" class="textBox hide" />
Javascript Code written inside $(document).ready
$(
'select').change(function () {
//alert('changed');
var others_option = $('option:selected', this).val();
if ((others_option) == 'others') {
$(
this).next().removeClass('hide');
}
else {
$(
this).next().addClass('hide');
}
});
The same thing obviously does not work with Rad ComboBox. I have tried in several ways, but couldn't make it. Can Somebody help...
Please find below a sample how to achieve this with RadComboBox.:
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
>
</
asp:ScriptManager
>
<
telerik:RadComboBox
ID
=
"RadComboBox1"
runat
=
"server"
OnClientSelectedIndexChanged
=
"clientChanged"
>
<
Items
>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"RadComboBoxItem1"
Value
=
"RadComboBoxItem1"
/>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"RadComboBoxItem2"
Value
=
"RadComboBoxItem2"
/>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"RadComboBoxItem3"
Value
=
"RadComboBoxItem3"
/>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"others"
Value
=
"others"
/>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"RadComboBoxItem5"
Value
=
"RadComboBoxItem5"
/>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"RadComboBoxItem6"
Value
=
"RadComboBoxItem6"
/>
</
Items
>
</
telerik:RadComboBox
>
<
asp:TextBox
ID
=
"txtTitleOthers"
runat
=
"server"
class
=
"textBox hide"
/>
<
script
type
=
"text/javascript"
>
var $ = $telerik.$;
function clientChanged(sender, args)
{
var others_option = args.get_item().get_value();
if ((others_option) == 'others') {
$('#txtTitleOthers').removeClass('hide');
}
else {
$('#txtTitleOthers').addClass('hide');
}
}
</
script
>
Hope it helps.
Regards,
Helen
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.