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

reordering rows with bound data

13 Answers 303 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 11 Dec 2010, 04:29 PM

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

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 11 Dec 2010, 04:33 PM
Hi Andrew,

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
Richard
0
Andrew
Top achievements
Rank 1
answered on 12 Dec 2010, 06:22 AM

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?

0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 07:31 PM
Hi Andrew,

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.
Thanks
Richard
0
Andrew
Top achievements
Rank 1
answered on 13 Dec 2010, 08:24 AM

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. 

0
Richard Slade
Top achievements
Rank 2
answered on 13 Dec 2010, 11:25 AM
Hi Andrew, 

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
Richard
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 13 Dec 2010, 05:06 PM
Hi Andrew,

This seems to work for me.. Add the following to your Form1.cs

private void radGridView2_CellEndEdit(object sender, GridViewCellEventArgs e)
{
    this.radGridView1.TableElement.UpdateView();
}

let me know if that helps. I think you are running the older version of the controls and TableElement may be GridElement in yours.
Richard
0
Andrew
Top achievements
Rank 1
answered on 13 Dec 2010, 10:24 PM

Hello, 

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?

0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 14 Dec 2010, 12:37 AM
Hi Andrew,

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
Richard
0
Andrew
Top achievements
Rank 1
answered on 14 Dec 2010, 08:47 AM

Thanks very much for the support, Richard. 

Will see if I can arrange a purchase. 

0
Richard Slade
Top achievements
Rank 2
answered on 14 Dec 2010, 08:51 AM
Glad to have been able to help Andrew.
All the best
Richard
0
BILLY
Top achievements
Rank 1
answered on 25 Feb 2012, 06:11 AM
using Q3 2011 controls, is this possible yet to reorder rows in a radgridview that's databound?
0
JustinWong
Top achievements
Rank 1
answered on 28 Feb 2012, 05:26 AM
Same question. I would like to be able to reorder rows when the grid is bound to a dataTable. I'm curious as to why this is not implemented.
0
Stefan
Telerik team
answered on 29 Feb 2012, 01:51 PM
Hello Billy, Justin,

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.
 
Regards,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Andrew
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Andrew
Top achievements
Rank 1
BILLY
Top achievements
Rank 1
JustinWong
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or