Initially i am binding the dropdown control.
After that based on selection of grid value , i want to set the value of combo box.
How to set selected value at run time ?
I've tried following but it is not working
function
RowSelected(sender, args)
{
var combo = <%=cmbCondQn.ClientID %>;
var value = args.getDataKeyValue("Question");
combo.FindItemByText(value).Selected =
true;
}
Below is my grid code
<
telerik:RadGrid ID="RadGrid1"
Width="97%" AllowSorting="True" PageSize="15" AllowPaging="True" runat="server" AllowAutomaticDeletes="True"
Gridlines="None" DataSourceID="dsConditionalQuestion" OnItemDataBound="RadGrid1_ItemDataBound" OnItemDeleted="RadGrid1_ItemDeleted"><%--OnRowCommand="RadGrid1_RowCommand" OnRowDataBound="RadGrid1_RowDataBound" OnRowDeleted="RadGrid1_RowDeleted" OnRowDeleting="GridView1_RowDeleting"--%>
<MasterTableView Width="100%" AutoGenerateColumns="false" DataSourceID="dsConditionalQuestion" DataKeyNames="ID"
ClientDataKeyNames="Question,Answer,Action,Dependent_QuestionID" >
<
ClientSettings>
<Selecting AllowRowSelect="true" />
<ClientEvents OnRowSelected="RowSelected" />
</ClientSettings>
</telerik:RadGrid>
Regards,
Lubna.
14 Answers, 1 is accepted
combo.FindItemByText(value).Select()
Kind regards,
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.
Thanks for the reply.
But it is giving error "Object doesnot support this property or method."
Here is my combobox declaration
<
telerik:RadComboBox ID="cmbCondQn" runat="server" DataSourceID="dsQuestion"
DataTextField="Question" DataValueField="ID" OnSelectedIndexChanged="cmbCondQn_OnSelectedIndexChanged"
AutoPostBack="true"></telerik:RadComboBox>
Below is my javascript. I am getting correct values in alert but it is giving error when I set the combobox value.
function
RowSelected(sender, args)
{
var combo = <%=cmbCondQn.ClientID %>;
alert(combo);
var value = args.getDataKeyValue("Question");
alert(value);
combo.FindItemByText(value).Select();
}
Regards,
Lubna.
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.
I'm using Telerik 2009.3.1314.35
RowSelected(sender, args)
{
var
combo = $find(
"<%=cmbCondQn.ClientID %>"
);
alert(combo);
var
value = args.getDataKeyValue(
"Question"
);
alert(value);
combo.findItemByText(value).select();
}
Best wishes,
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.
Many thanks for the solution.
I was just trying to set the combo box with value field by replacing
findItemByText with findItemByValue
but it is not working. Below is my code.var
combo = $find("<%=cmbDepQn.ClientID %>");
value = args.getDataKeyValue(
"Dependent_QuestionID");
combo.findItemByValue(value).select();
<
telerik:RadComboBox ID="cmbDepQn" runat="server" DataSourceID="dsQuestion" DataTextField="Question"
DataValueField="ID"></telerik:RadComboBox>
Regards,
Lubna.
combo.findItemByValue(value).select(); is working fine :))
I have almost the same case, but i have a tree inside the combobox (both are telerik), in the ComboTreeNodeClicking event, i set the text and the value of the combo box using the following JS code
combo.set_text(node.get_text()); |
combo.set_value(node.get_value()); |
any suggestions?
combo.trackChanges();
combo.get_items().getItem(0).set_value(node.get_value());
combo.commitChanges();
Regards,
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.
one more question, How to get a reference to the parent combo from the nodeclicking event?
http://www.telerik.com/community/forums/aspnet-ajax/treeview/radtreeview-reference-to-parent-radcombobox.aspx
it works, but it might get buggy, imagine the combo box (or any control in the hierarchy) starts with an "i"!!
anyhow, i will use it.
P.S. cannot this be in the Client APIs of the treeview? actually, i am thinking of a built in Combobox with a treeview. nice to have in telerik.
might do it myself :D
Another way would be to set the ClientID of the RadComboBox as a custom attribute to the RadTreeView, e.g.
treeView.Attributes.Add(
"parentComboBoxId"
, comboBox.ClientID);
Then, on the client, in the NodeClicking event of the RTV you can get this attribute and use it with the $find function to get the client-side RCB reference, e.g.
var
parentComboBoxId = sender.get_attributes().getAttribute(
"parentComboBoxId"
);
var
comboBox = $find(parentComboBoxId);
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.
What is the error you are receiving?
As an alternative you can try another approach: handle the client-side Load event of the RadComboBox and set a global variable to the control's object.
var
parentComboBox;
function
onLoad(sender) {
parentComboBox = sender;
}
function
onNodeClicking(sender, eventArgs) {
// parentComboBox
}
Later in the RadTreeView event handlers you can use the global variable to reference the RCB.
All the best,
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.