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

Drag from RadGrid to RadTree

3 Answers 41 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Roger
Top achievements
Rank 2
Veteran
Roger asked on 27 Nov 2008, 06:02 PM
Hi:

I have a RadGrid and RadTree that are tied to a SqlServer database.  When I click on a node which is represended by a Category ID, it brings up a list in the Grid of all Products that have that CategoryID.  I would like to be able to drag a row from the grid to another  node on the tree and update the database so that that product now shows up under the new category.

I am able to extract the ProductID in the NodeDrop event.  What I am having difficulty doing is extracting the CategoryID from the node that I am hovering over.  Partly this has to do with my limited ability to speak javascript.  Any help in doing this would be greatly appreciated.

Roger

3 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 01 Dec 2008, 02:22 PM
Hello Roger,

You could handle the OnClientMouseOver event to obtain a reference to the currently hovered Node (as is shown here).

In the event handler, use eventArgs.get_node().get_category() method to get the category of the Node.

I hope this will get you started.

Sincerely yours,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Roger
Top achievements
Rank 2
Veteran
answered on 02 Dec 2008, 05:45 AM
Hi Simon - thanks for this -

I created a little function as per the instructions your referred to which is 

function

ClientMouseOver(sender, eventArgs)

 

{

 

var node = eventArgs.get_node();

 

 

var myDiv = document.getElementById("myDiv");

 

myDiv.innerHTML =

"Category: " + node.get_text() + " - " + node.get_category();

 

}

The .get_text works find and I get the text of the node I am hovering over but the .get_category gives me null all the time.  Now, my tree is being fed by a sql server table - would that affect anything.  Also, if I am able to get the value of the CategoryID this way, could you tell me where I should call it from - I'm just feeling my way around here - would it be on the RadGrid1_RowDrop event - if so how?

Thanks for your patience.
Roger

0
Simon
Telerik team
answered on 02 Dec 2008, 02:03 PM
Hello Roger,

First make sure the Category property is properly filled with data. In case the TreeView is data bound you could use the following DataBinding:

<DataBindings> 
    <telerik:RadTreeNodeBinding CategoryField="CategoryID" /> 
</DataBindings> 

As for retrieving the CategoryID value upon row dropping you could do this depending on your implementation.

Please see this Code Library project for a sample implementation of this approach. In the project you could get any value from the destination Node in the RadAjaxManager.AjaxRequest server-side event handler.

Greetings,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Roger
Top achievements
Rank 2
Veteran
Answers by
Simon
Telerik team
Roger
Top achievements
Rank 2
Veteran
Share this question
or