Auto expand node on drag over on a RadTreeListView

5 posts, 0 answers
  1. Luzius
    Luzius avatar
    14 posts
    Member since:
    Jun 2010

    Posted 25 Jan 2012 Link to this post

    Hi

    The RadTreeView offers the ability to automatically expand when dragging items over a node. How do I achieve this on a RadTreeListView. Is there a sample out there?

    Thanks,
    Luzius
  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 26 Jan 2012 Link to this post

    Hello,

    By design the TreeList does not provide this functionality. You can however implement the functionality quite easily using The DragDropManager. You can use the DragOver event to expand the desired row. You can read more about the DragDropManager here.
    Mind however that the DragDrop operation must not depend on the source UI element. It should rather rely on the underlying item. The reason this is required is that when a row is expanded, the whole TreeList is refreshed. Therefore, there is no way to be sure that the source UI item is the actual one, since the TreeList reuses its rows when its refreshed. 

    Hope this helps! 

    Kind regards,
    Nik
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Luzius
    Luzius avatar
    14 posts
    Member since:
    Jun 2010

    Posted 26 Jan 2012 Link to this post

    Hello Nik,

    I'm using the RadDragAndDropManager which doesn't implement a DragOver event. Do I have to change my implementation or is there a way using the RadDragAndDropManager?

    Thanks,
    Luzius
  5. Nick
    Admin
    Nick avatar
    593 posts

    Posted 30 Jan 2012 Link to this post

    Hello Luzius,

    You can use the equivalent event in the RadDragAndDropManager. The DropQuery event with status DropDestinationQuery, gives you the same functionality as the DragOver event. 

    Hope this helps!

    Greetings,
    Nik
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Luzius
    Luzius avatar
    14 posts
    Member since:
    Jun 2010

    Posted 30 Jan 2012 Link to this post

    Hello Nik,

    I implemented it using a timer class derived from DispatcherTimer.
    At the DropInfoHandler I inserted the following code.
    if (row.IsExpandable && !row.IsExpanded)
    {
        if (_ExpNodeTimer.row != row)
        {
            _ExpNodeTimer.Stop();
            _ExpNodeTimer.row = row;
            _ExpNodeTimer.Start();
        }
    }
    else
        _ExpNodeTimer.Stop();

    At the timer tick handler I call the Expand function of my timer class to expand the row.
    void ExpNodeTimer_Tick(object sender, EventArgs e)
    {
        ((DelaydExpNodeDspTmr)sender).Stop();
        if (RadDragAndDropManager.IsDragging)
            ((DelaydExpNodeDspTmr)sender).Expand();
    }

    I'm not quite sure if this is a good practice but it works for me so far.



Back to Top
DevCraft banner