I have an invisible field on a page that I populate with a reference ID. How do I get this value into a RadComboBox SelectedValue property at runtime so the combo box has the default (invisible field value) selected when the window comes up?
Thanks,
Joe B
4 Answers, 1 is accepted
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 24 Mar 2010, 03:03 AM
Clientside or serverside?
//Serverside
int index = RadComboBox1.FindItemIndexByValue(hiddenField.Value);
RadComboBox1.SelectedIndex = index;
//clientside
//Serverside
int index = RadComboBox1.FindItemIndexByValue(hiddenField.Value);
RadComboBox1.SelectedIndex = index;
//clientside
function SelectComboBoxItem(itemText) |
{ |
var combo = $find("<%= RadComboBox1.ClientID %>"); |
var item = combo.findItemByValue(hiddenValue); |
if(item) |
{ |
item.select(); |
} |
} |
0
Brad
Top achievements
Rank 2
answered on 25 Mar 2010, 06:17 PM
Client side, but the combobox is in a table in a formview in a radpageview in a radmultipage and I keep getting an error message:
"The name 'EmployeeCB' does not exist in the current context"
But the combobox IS named that!
<telerik:RadMultiPage ID="WORForms" runat="server" SelectedIndex="2" BorderStyle="Outset"
BorderWidth="2px" BackColor="#E7EFFF" SkinID="Outlook" Width="934px">
...
...
<telerik:RadPageView ID="TimeEntry" runat="server" CssClass="WORFormPage" BorderStyle="None"
...
...
<asp:FormView ID="TimeEntryForm" runat="server" DataSourceID="TimeLastEntry" DefaultMode="Edit">
<EditItemTemplate>
<table style="width: 930px; background-color: #E7EFFF; border: none; border-collapse: collapse;"
<telerik:RadComboBox ID="EmployeeCB" DataSourceID="DeveloperList" DataTextField="Developer"
DataValueField="ID" Height="100px" AppendDataBoundItems="true" runat="server"
Skin="Outlook" Width="146px" OnClientLoad="SelectComboBoxItem">
</telerik:RadComboBox>
...
...
Here is the function:
function SelectComboBoxItem(itemText) {
var worMPage = document.getElementById("WORForms");
var tePage = worMPage.$find("<%= TimeEntry.ClientID %>");
var teForm = tePage.$find("<%= TimeEntryForm.ClientID %>");
var combo = teForm.$find("<%= EmployeeCB.ClientID %>");
var devid = document.getElementById("DEVID").value;
var item = combo.findItemByValue(devid);
if (item) {
item.select();
}
}
Any ideas??????
Thanks,
Joe B
0
Accepted
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 25 Mar 2010, 06:26 PM
Probably because it's so nested
What if you change your code to use a bunch of nested FindControls to dig down to it...
OR use jQuery to try and locate it
What if you change your code to use a bunch of nested FindControls to dig down to it...
OR use jQuery to try and locate it
var comboid = $telerik.$('[id$="EmployeeCB"]').attr('id); |
var combo = teForm.$find(comboid); |
0
Hi Joe,
In addition to Steve's approach you can also achieve this by handling the client-side Load event of that RadComboBox and use the sender parameter as it already holds a reference to the client-side object of the control:
function
onLoad(sender) {
var
comboBox = sender;
}
Greetings,
Simon
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Simon
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.