reordering rows with bound data

14 posts, 2 answers
  1. Andrew
    Andrew avatar
    9 posts
    Member since:
    Dec 2010

    Posted 11 Dec 2010 Link to this post

    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?

  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 11 Dec 2010 Link to this post

    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
  3. Andrew
    Andrew avatar
    9 posts
    Member since:
    Dec 2010

    Posted 12 Dec 2010 Link to this post

    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?

  4. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 12 Dec 2010 Link to this post

    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
  5. Andrew
    Andrew avatar
    9 posts
    Member since:
    Dec 2010

    Posted 13 Dec 2010 Link to this post

    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. 

  6. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 13 Dec 2010 Link to this post

    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
  7. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 13 Dec 2010 Link to this post

    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
  8. Andrew
    Andrew avatar
    9 posts
    Member since:
    Dec 2010

    Posted 13 Dec 2010 Link to this post

    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?

  9. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 13 Dec 2010 Link to this post

    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
  10. Andrew
    Andrew avatar
    9 posts
    Member since:
    Dec 2010

    Posted 14 Dec 2010 Link to this post

    Thanks very much for the support, Richard. 

    Will see if I can arrange a purchase. 

  11. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 14 Dec 2010 Link to this post

    Glad to have been able to help Andrew.
    All the best
    Richard
  12. BILLY
    BILLY avatar
    3 posts
    Member since:
    Dec 2011

    Posted 25 Feb 2012 Link to this post

    using Q3 2011 controls, is this possible yet to reorder rows in a radgridview that's databound?
  13. JustinWong
    JustinWong avatar
    147 posts
    Member since:
    Mar 2007

    Posted 27 Feb 2012 Link to this post

    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.
  14. Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 29 Feb 2012 Link to this post

    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 >>
Back to Top