I have a radtreeview inside radcombobox. My treeview is populated on demand. This combobox resides inside formview which is by default in edit mode. And i have an objectdatsource that contains the select and update mode.
The problem with my update mode is, the selected value of combox always becomes 0 it doesn't change even when using combo.set_value("something");
In client side the value changes but not in server side even when trackChanges() and commitChanges() is applied.
The following link contains the type of solution but its not working, with my q1 2008 415 version. it has a special parameter called <telerik:AjaxComboValueParameter />. Wouldn't it be better if that parameter would be provided by Telerik instead of trying to code it.
http://www.telerik.com/community/code-library/submission/b311D-ttdgm.aspx
Following is my javascript file for setting the value of the combobox when selecting a treenode. My objectdatasource update parameter contains <asp:ControlParameter Name="parentId" Type="Int32" ControlID="cbo" PropertyName="SelectedValue" />. The name of my radcombox inside formview edit mode is cbo and treeview is radPortalsTree.
function radTreeViewPortalParent_OnClientNodeClicking(sender,eventArgs)
{
var comboBox=$find('<%=FormViewPortal.FindControl("cbo").ClientID%>');
var node=eventArgs.get_node();
var portalTree=$find('<%= radPortalsTree.ClientID %>');
if(portalTree.get_selectedNode().get_value()!=node.get_value())
{
comboBox.trackChanges();
comboBox.set_text(node.get_text());
comboBox.set_value(node.get_value());
var cboItem=comboBox.get_items().getItem(0);
cboItem.set_value(node.get_value());
comboBox.commitChanges();
}
comboBox.hideDropDown();
}
13 Answers, 1 is accepted
Welcome to Telerik Community!
I suggest that you follow this order in your NodeClicking event handler:
| comboBox.trackChanges(); |
| var cboItem=comboBox.get_items().getItem(0); |
| cboItem.set_value(node.get_text()); |
| comboBox.set_text(node.get_text()); |
| comboBox.commitChanges(); |
I hope this helps.
Regards,
Veskoni
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I believe that the best way to proceed would be if you isolate the problem in a small and running project and attach the files to a new support thread. We will test your project locally and try to find a working solution for you.
Kind regards,
Nick
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
http://www.prabirshrestha.com/telerikProblem.zip
Could you please have a look at it.
Im using .net 3.5 and sql express and have not included the Telerik's .dll files. im using the radcontrols asp.net ajax 2008 q1.
How do i send the value of combobox to sqldatasource which is set from the client side using set_value().
note:
i have changed from objectdatasource to sqldatasource for easier code.
<asp:ControlParameter Name="parentId" Type="Int32" ControlID="FormView1$cboParentId" PropertyName="SelectedValue" />
buy when i used the object datasource. it wouldn't change.
i have uploaded the problem with object datasource in the following website
http://www.prabirshrestha.com/telerikproblem2.zip
<UpdateParameters>
<asp:Parameter Name="Name" />
<asp:Parameter Name="id" Type="Int32" />
<asp:ControlParameter Name="parentId" Type="Int32" ControlID="FormView1$cboParentId" PropertyName="SelectedValue" />
</UpdateParameters>
but when i converted it to objectdatasource, i was not able to fix it. the update version of the website with object datasource has been uploaded to the following website.
http://www.prabirshrestha.com/telerikproblem2.zip
i would like the parent id of combobox to change when i click update in the formview.
I have changed the tvParentId_OnClientNodeClicking javascript function and now the ParentID is passed correctly:
| function tvParentId_OnClientNodeClicking(sender,eventArgs) |
| { |
| var comboBox=$find('<%=FormView1.FindControl("cboParentId").ClientID%>'); |
| var node=eventArgs.get_node(); |
| var portalTree=$find('<%= tvMain.ClientID %>'); |
| if(portalTree.get_selectedNode().get_value()!=node.get_value()) |
| { |
| comboBox.trackChanges(); |
| var cboItem=comboBox.get_items().getItem(0); |
| cboItem.set_value(node.get_value()); |
| comboBox.set_text(node.get_text()); |
| comboBox.commitChanges(); |
| comboBox.trackChanges(); |
| comboBox.set_value(node.get_value()); |
| comboBox.commitChanges(); |
| } |
| comboBox.hideDropDown(); |
| } |
Now if you put a breakpoint into the Update method you will notice that the parentID is correct, but the id is always 0. This is weird. Please try it and let me know how it goes.
Greetings,
Veskoni
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
if u look at the code, supposei click a treeview at the left . for examplecategories>electronics>mobile. and click the update button in theformview, the parentId is always reseted to 0(that is if i don't select a node from treeview). so how to set the initial value of the combobox to the parentId?
I have modified your files a bit and attached the project again.
Greetings,
Veskoni
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
But actually my databasce table is a bit different. For simpicity I didn't put LineageName column (sorry for not informing you this earlier), which is auto calculated by using triggers.
For example for Mobile the LineageName would have the value /Electronics/Mobile/
for toshiba it would have /Electronics/Computer/Toshiba.
So i actually use <telerik:RadComboBox runat="server" ID="cboParentId"
Text='<%# Eval("LinageName") %>' ........> so the text of combobox is more user friendly then just putting the id, which the user might not find comfortable to workwith.
so i came up with a really wierd idea of putting ToolTip='<%#Eval("ParentId")%>' and then changing the follwing code
function OnClientLoadHandler(sender, eventArgs)
{
sender.trackChanges();
var item = sender.get_items().getItem(0);
item.set_value(sender.get_inputDomElement().title);
sender.set_value(sender.get_inputDomElement().title);
sender.commitChanges();
}
That means my tooltip contains the parentid, text contains the lineagename which is user friendly. so this accomplishes my task.
but i reallized that why not make the tooltip also user friendly so it also contains lienage name.
So the final solution: get the text from <asp:label ID="Label1" runat="server" Text='<%# Eval("ParentId") %>' /> which is already databound. (why wasn't i thinkin about this before? instead of again trying to databind the parenid to combobox.)
so my final javascript funciton looks as below:
function OnClientLoadHandler(sender, eventArgs)
{
sender.trackChanges();
var item = sender.get_items().getItem(0);
var parentId=$get('<%=FormView1.FindControl("lblParentId").ClientID %>').innerText;
item.set_value(parentId);
sender.set_value(parentId);
sender.commitChanges();
}
you might be wondering why innerText, thats because asp:label is rendered as span tags, so to get access to the Text propery of label use innerText so u can access inner text of span tags.
incase u want to use asp:hiddenfield might be in some other examples:
use the same code but modifiy it to be $get('......').value instead.
Thats the solution I had been trying to solve for almost a month, and now after getting support from telerik, its finally done.
Note: I will be deleting the telerikproblem zip files from my website(prabirshrestha.com) soon, because if anyone of you have the same problem you can download from the telerik post which was posted on 5/10/2008 9:42:26 AM. or from direct link below:
http://www.telerik.com/ClientsFiles/085057_telerikproblem3.zip
Please note that the changes i made in this current post is not updated on tat file, so please change according.
Thanks, Veskoni (from the Telerik team).
u guys rock
I am glad to hear that you have solved the problem.
Thank you for sharing your approach with the other members of the community. I am sure it will be helpful for someone.
Best wishes,
Veskoni
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
| function tvParentId_OnClientNodeClicking(sender,eventArgs) |
| { |
| var comboBox=$find('<%=FormView1.FindControl("cboParentId").ClientID%>'); |
| var node=eventArgs.get_node(); |
| var portalTree=$find('<%= tvMain.ClientID %>'); |
| if(portalTree.get_selectedNode().get_value()!=node.get_value()) |
| { |
| comboBox.trackChanges(); |
| var cboItem=comboBox.get_items().getItem(0); |
| cboItem.set_value(node.get_value()); |
| comboBox.set_text(node.get_text()); |
| comboBox.commitChanges(); |
| comboBox.trackChanges(); |
| comboBox.set_value(node.get_value()); |
| comboBox.commitChanges(); |
| } |
| comboBox.hideDropDown(); |
| } |
i didn't understand why you put trackchanges() and commitChanges() twice and even highlighted it. isn't one more than enough.
why twice? wouldn't it have funtion overhead and those stuffs...
wouldn't it be fine if it was called only once.
You are right, these two lines are not needed in this case.
Thanks for pointing that.
Greetings,
Veskoni
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
