Drag from RadGrid to RadTree

4 posts, 0 answers
  1. Roger
    Roger avatar
    21 posts
    Member since:
    Nov 2008

    Posted 27 Nov 2008 Link to this post

    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
  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 01 Dec 2008 Link to this post

    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.
  3. Roger
    Roger avatar
    21 posts
    Member since:
    Nov 2008

    Posted 01 Dec 2008 Link to this post

    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

  4. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 02 Dec 2008 Link to this post

    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.
Back to Top