When I attempt to enable row reordering with a gridview bound to a DataTable rather than manually adding rows like in the demo application, nothing happens.
Is it possible to make reordering or drag/drop work when bound to a DataTable?
13 Answers, 1 is accepted
Out-of-the-box, this isn't a supported feature, but you should have a look at Emanuel's Code Library Article on drag and drop in bound mode which will help you to do this.
Hope this helps
Thanks Richard, that example was helpful and now I am partway to implementing dragging and moving. I have one more issue I would like to ask about, I'm binding the gridView to esentially a tree data structure. Each node exposes an integer index and parentIndex which I create a grouping relation with.
I have implemented IPropertyChanged on all properties exposed to the grid and maintain the nodes in a BindingList. When I add/remove items from the list, the grid refreshes. When I change the text property of a node, the grid refreshes. When I change the parentIndex property, its column gets updated but the relation does not. The changed parent only refreshes if I manually fold/unfold an item in the grid or the list is modified. How can I refresh the relation?
Sorry for the delay. for some reason my forum subscriptions are not picking up that I am subscribed to this thread. Anyhow, do you have a basic exmaple that you can post, and i will happily take a look at it for you.
Please find vs2010 solution demonstrating this at www.messy-mind.net/temporary/TreeDemo.zip
Expand the Folder elements on the left treeview. Select Element 5 child node. Use the right treeview to change its ParentIndex to 1.
No change occurs in the left treeview. If you attempt to collapse Folder 2, the collapse/expand box vanishes. If you collapse/expand Folder 1, Element 5 does not show in it.
If you hit force refresh, the relation is cleared and re-added, the left treeview works correctly again.
Just to let you know that I have downloaded your solution and I'm looking at it. I haven't made any progress on it at the moment as I have quite a busy day, but I will continue to look at it for you. I see though that you are using an older version of the controls, but for reference it doesn't update with the latest version either. I'll come back to you as soon as I can
This seems to work for me.. Add the following to your Form1.cs
sender, GridViewCellEventArgs e)
let me know if that helps. I think you are running the older version of the controls and TableElement may be GridElement in yours.
I tried your code and also using GridElement instead as I am using an older version, but neither worked. Before buying the new version I'd like to be sure that this feature works correctly in it. In my application the ParentIndex may be changed by business logic not coupled to the UI so I need the gridview to update without it being explicitly called. Or will I need to subscribe to PropertyChanged and ListChanged in my form in order to call this update?
Without seeing your exact scenario, I'm not entirely sure, but I know I don't usually have to explicitly call a refresh or update on the grid. I have added the code that I suggested to to your demo that you made available and I have taken a short video which I have posted on screencast to show you it working.
the move can be found here
I hope that this helps. I would say that there are a lot of enhancements, especially with performance with the later versions, especially after Q2 2010 when the new UI Virtualization system was introduced.
Hope this helps, but let me know if there's anything else I can do.
All the best
Thanks very much for the support, Richard.
Will see if I can arrange a purchase.
All the best
Thank you guys for writing.
The desired functionality is not yet supported by our controls. The reason for this is that bindings to DataTable are in fact bindings to the DataView rather then to the table itself. As you probably know the DataView does not support Insert, Clear or other operations, which is the reason for not providing this feature yet.
For the time being, everyone who needs such a functionality can implement it, considering its binding scenario, just like Emanuel did for DataSet and BusinessObjects in this article: http://www.telerik.com/community/code-library/winforms/gridview/drag-and-drop-in-bound-mode.aspx.
I hope that you find this information helpful.
the Telerik team