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

How do you drag/drop before/after in a gridview?

4 Answers 39 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 17 Dec 2010, 06:33 AM
How do you drag/drop before/after in a gridview?

When draging from within a gridview, to the same gridview, I've noticed with the  "draged" item (InvoiceItem, for me) when draged over the top of a particular row, it says

Drop Before xyz
And if you drag from the from the middle/towards the end it says Drop Insert after xyz

Now I can easily get a reference to the two row's (and the backing entities via their DataContexts')
e.GetElement<GridViewRow>(E.Options.CurrentDragPoint)
e.Source



1. But how can I tell if I'm suppose to drop before/after? And can I customize what it displays ? ( e.g. Right now it is showing DataContext.ToString() )


2. Also, am I doing this correctly?

(I'm manually ~reordering, by changing a line number value on my Entities)

4 Answers, 1 is accepted

Sort by
0
Accepted
Pavel Pavlov
Telerik team
answered on 17 Dec 2010, 12:15 PM
Hi Alex,

In our online example you may click the "View Code" tab above the example.
In the RowReorderBehavior.cs file , there is a method called GetDropPositionFromPoint.

It is the core of the logic to identify the drop position ( before/after).

All the best,
Pavel Pavlov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
jean-Marc
Top achievements
Rank 1
answered on 08 Jan 2011, 02:29 AM
Hi Telerik Team,
I am currently implementing a similar solution where I (to simplify) wants to manage the elements in my gridview to "bulk assign" them to a group.
The main difference with the online example is that my grid view is using GroupDescriptors, right now it is limited to a single grouping level but plan to extend...so my gridView is grouping by "GroupName", when I drag and drop 1 or many items to another group, I changed in the GridDropInfo method to assign the same GroupName as my currentDropItem and it is working fine EXCEPT that i need a call to GridView.Rebind(); after manipulating the items source list...problem is that it seems a bit slow when rebinding...
On your example I note that you do not rebind but again you just change the index of the item ..
I was wondering if this was due to my grouping, and mainly if you could suggest me maybe an alternative approach?

thanks in advance
Regards
Jean-Marc
0
Tsvyatko
Telerik team
answered on 10 Jan 2011, 01:10 PM
Hi jean-Marc,

The reason you need to rebind the grid in order to update the changes if due to the fact the grid does not listens to Property change to update its groups. This is done to optimize the performance.

In this scenario, I can recommend to artificially raise collection change with replace to force group refresh.
Please, check the attached project as well this blogpost and let me know if this works for you.

Greetings,
Tsvyatko
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
jean-Marc
Top achievements
Rank 1
answered on 21 Feb 2011, 12:52 AM
Hi Tsvyatko,
sorry had to put this one aside for a while and thus never had a chance to follow your recommendations.
I just did it now and works fine.
thanks then to You and Vladimir post.
Regards
Jean-Marc
Tags
GridView
Asked by
Alex
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
jean-Marc
Top achievements
Rank 1
Tsvyatko
Telerik team
Share this question
or