Hi,
I would like to enable row reordering in some of our grids. I've found this example quite helpful: http://demos.telerik.com/Silverlight/#GridView/RowReorder (and this looks like the same code: http://docs.telerik.com/devtools/silverlight/controls/dragdropmanager/how-to/howto-draganddrop-within-radgridview.html).
Please advise how I could implement these:
I would like to enable row reordering in some of our grids. I've found this example quite helpful: http://demos.telerik.com/Silverlight/#GridView/RowReorder (and this looks like the same code: http://docs.telerik.com/devtools/silverlight/controls/dragdropmanager/how-to/howto-draganddrop-within-radgridview.html).
Please advise how I could implement these:
- Expose an event that could be set on the grid similarly to local:RowReorderBehavior.IsEnabled="True" (e.g. local:RowReorderBehavior.RowMoved="Grid_RowMoved"). I would expect the even to be raised from RowReorderBehavior.OnDrop. This would be helpful when grid's ItemsSource is bound to a collection. Each item in our ItemsSource has a DisplayOrder property, which is used in a SortDescriptor.
- Indicate the drop position in the grid itself. Something like a line between the rows where the moved row will be inserted.
6 Answers, 1 is accepted
0
Mark
Top achievements
Rank 1
answered on 11 Mar 2015, 01:43 AM
Another question related to row ordering. When an item member (a property of row's DataCotext) is updated, to which a SortDescriptor is bound, the row order does not update automatically. Calling Rebind on the grid does not seem to do anything either. Is adding and removing SortDescriptors the only way to reorder the rows in this case?
0
Hello,
As to your questions:
1. I am afraid we cannot suggest such an event. You can refer to our Drag and Drop examples for a further reference.
2. You can check the definition and usage of HideDropPositionFeedbackPresenter in the mentioned help article.
3. When RadGridView is sorted, then the order of the items cannot be changed with a simple drag and drop as it should remain ordered as defined through a SortDescriptor. Do you experience a different problem? If so, may I ask you to open a new support ticket on the matter providing some more details on the exact case?
Regards,
Dimitrina
Telerik
As to your questions:
1. I am afraid we cannot suggest such an event. You can refer to our Drag and Drop examples for a further reference.
2. You can check the definition and usage of HideDropPositionFeedbackPresenter in the mentioned help article.
3. When RadGridView is sorted, then the order of the items cannot be changed with a simple drag and drop as it should remain ordered as defined through a SortDescriptor. Do you experience a different problem? If so, may I ask you to open a new support ticket on the matter providing some more details on the exact case?
Regards,
Dimitrina
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Mark
Top achievements
Rank 1
answered on 17 Mar 2015, 01:27 AM
Hi Dimitrina,
Thanks for your help.
Regarding the third question, looks like the behaviour we are experiencing is correct - the order of items in a sorted RadGridView cannot be changed with a drag-and-drop.
Our intention is to bind grid's ItemsSource to a collection and allow the user to reorder the items. Could you advise how this could be achieved?
Thanks,
Mark
Thanks for your help.
Regarding the third question, looks like the behaviour we are experiencing is correct - the order of items in a sorted RadGridView cannot be changed with a drag-and-drop.
Our intention is to bind grid's ItemsSource to a collection and allow the user to reorder the items. Could you advise how this could be achieved?
Thanks,
Mark
0
Hi Mark,
As to your question, does the approach suggested in the referred demo (http://demos.telerik.com/Silverlight/#GridView/RowReorder) not work for you? It illustrates how you can reorder the items.
Regards,
Dimitrina
Telerik
As to your question, does the approach suggested in the referred demo (http://demos.telerik.com/Silverlight/#GridView/RowReorder) not work for you? It illustrates how you can reorder the items.
Regards,
Dimitrina
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Mark
Top achievements
Rank 1
answered on 18 Mar 2015, 01:22 AM
Hi Dimitrina,
The approach in the demo might work for us as long as the items can be displayed in the same order the next time they are loaded into the grid. For this, I we would need to save the positions of the items (likely on the item entities in the database). Please advise whether the demo can be extended to achieve this.
Also, if there is another grid on the page bound to the same collection (ItemsSource), would it be possible to synchronise the position of the items after dragging them?
Thanks,
Mark
The approach in the demo might work for us as long as the items can be displayed in the same order the next time they are loaded into the grid. For this, I we would need to save the positions of the items (likely on the item entities in the database). Please advise whether the demo can be extended to achieve this.
Also, if there is another grid on the page bound to the same collection (ItemsSource), would it be possible to synchronise the position of the items after dragging them?
Thanks,
Mark
0
Hi Mark,
The concrete implementation of the action on drop is actually up to you. Our DragDropManager is a wrapper over the WPF drag and drop events and it gives several options when any of its event is raised. In the example, we remove the item from the collection and then insert it at a specific index where it was dropped.
You can also handle the case in any other way. As to persisting any order, RadGridView does not have such a built-in option. The closest example I may suggest is the GridView Serialization demo showing how to save and load different settings using the PersistenceFramework.
Regards,
Dimitrina
Telerik
The concrete implementation of the action on drop is actually up to you. Our DragDropManager is a wrapper over the WPF drag and drop events and it gives several options when any of its event is raised. In the example, we remove the item from the collection and then insert it at a specific index where it was dropped.
private
void
OnDrop(
object
sender, Telerik.Windows.DragDrop.DragEventArgs e)
{
var draggedItem = DragDropPayloadManager.GetDataFromObject(e.Data,
"DraggedItem"
);
var details = DragDropPayloadManager.GetDataFromObject(e.Data,
"DropDetails"
)
as
DropIndicationDetails;
...
if
(e.Effects == DragDropEffects.Move || e.Effects == DragDropEffects.All)
{
((sender
as
RadGridView).ItemsSource
as
IList).Remove(draggedItem);
}
if
(e.Effects != DragDropEffects.None)
{
var collection = (sender
as
RadGridView).ItemsSource
as
IList;
int
index = details.DropIndex < 0 ? 0 : details.DropIndex;
index = details.DropIndex > collection.Count - 1 ? collection.Count : index;
collection.Insert(index, draggedItem);
}
}
You can also handle the case in any other way. As to persisting any order, RadGridView does not have such a built-in option. The closest example I may suggest is the GridView Serialization demo showing how to save and load different settings using the PersistenceFramework.
Regards,
Dimitrina
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.