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

Drag to Grid and get position

3 Answers 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 05 Apr 2011, 05:12 PM
I have a treeview that the user can drag items from and drop them on a grid.  Currently the dropped items go to the bottom of the grid.  Is there a way I can get the row that the user dropped the items on?

The method that handles the drop is :

protected void tvReportColumn_HandleDrop(object sender, RadTreeNodeDragDropEventArgs e)
{
    RadTreeNode sourceNode = e.SourceDragNode;
    RadTreeNode destNode = e.DestDragNode;           
    if ((e.HtmlElementID == RadGrid1.ClientID))
    {
        foreach (RadTreeNode node in e.DraggedNodes)
        {
            AddRowToGrid(node);                   
        }
    }
 
    RadGrid1.Rebind();
}

3 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 06 Apr 2011, 07:16 PM
Hello Jon,

You can perform this check on the client in the OnClientNodeDropping event like that:

var cell = args.get_htmlElement();
                    if (cell instanceof HTMLTableDataCellElement)
                    {
                        var row = cell.parentNode;
                        var arr = row.id.split('__');
                        var rowNumber = arr[1];
                    }

This will give you the zero-based number of the row in the grid that the item has been dropped on.


Kind regards,
Marin
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
0
Jon
Top achievements
Rank 1
answered on 07 Apr 2011, 02:29 PM
This is great for client side but I am doing this server side using onNodeDrop which accepts an object and  RadTreeNodeDragDropEventArgs.  How can I find the grid row on the server side?
0
Marin
Telerik team
answered on 07 Apr 2011, 07:44 PM
Hi Jon,

Unfortunately the treeview does not provide such API server-side. One workaround would be to retrieve the row number on the client, store it in a hidden field and then access it on the server in the OnNodeDrop event.

Best wishes,
Marin
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
Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Marin
Telerik team
Jon
Top achievements
Rank 1
Share this question
or