Home Forums WPF controls Xceed DataGrid for WPF Possibility to have a TreeView with DataGridControl

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #21792 |

    Hi,

    Is it possible to have a tree view in a data grid control ?

    With the basic controls of WPF(TreeView, GridViewRowPresenter and HierarchicalDataTemplate), I have something that works.

    I’m trying to figure out how to do the same thing with the data grid control but I didn’t find a way.

    Thank you

    Imported from legacy forums. Posted by Sébastien (had 6222 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    Could you please provide more details on what you are trying to achieve?

    Thanks!

    Imported from legacy forums. Posted by Pascal (had 795 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    I have two types of data : Client and Account.
    A client can have multiple accounts or no accounts.
    Both Client and Account have the same columns to be shown : Name, Amount, Currency.
    Is there a way to easily show both client and account data in the same grid.
    By default, only the client data is shown.
    Usually, in a tree there’s a ‘+’ icon that indicates that there is “sub-data” and when you click on it, the icon changes to ‘-‘ and the “sub-data” appears.

    The data could look like this:
    + Client1 1000$ USD
    + Client2 500$ USD
    + Client3 500$ USD

    After a click on the ‘+’ icon of Client2, the data would look like this:
    + Client1 1000$ USD
    – Client2 500$ USD
    Account2-1 250$ USD
    Account2-2 250$ USD
    + Client3 500$ USD

    Thanks

    Imported from legacy forums. Posted by Sébastien (had 492 views)

    User (Old forums)
    Member
    Post count: 23064

    There are many ways to approach this. I’ve built a small sample that shows one option, you can find it here:

    http://forums.xceed.com/attach/WPF/DataGrid/TreeViewDataGrid.zip

    My goal was to show that it is feasible, but this sample has some limitations, most of which are due to the fact that my sample sets the Visibility property to Collapsed on the Account DataRows that must be collapsed:

    – The RowSelectors for collapsed rows will still be displayed

    – If you have 1000 DataRows that are collapsed, those 1000 rows will exist in the VisualTree (they will not be virtualized)

    – Paging (PageUp/PageDown) might not always work as expected

    – The expanded/collapsed state of a Client has to be preserved in a property on the Client data object

    Ideally, you’d bind the DataGrid (ItemsSource) to an ObservableCollection which would be a flat view of your Clients/Accounts. That collection would manage the expanded/collapsed state of each Client, and whenever a Client becomes expanded or collapsed, you would add or remove the corresponding Accounts from the collection.

    This would remove all the limitations listed above.

    Hope this helps!

    Imported from legacy forums. Posted by Pascal (had 986 views)

    User (Old forums)
    Member
    Post count: 23064

    I tried out the sample. I have the following comments

    1. Sorting will screw up the Grid parent – child relation.
    2. The check box version does not look good.

    – Root 100 100
    – Child 10 10
    – child2 10 10
    +child3 10 10
    +child4 10 1

    something like the link
    http://www.codeproject.com/cs/miscctrl/treelistview.asp

    which is for .net2.0

    regards

    Mathew

    Imported from legacy forums. Posted by Mathew (had 507 views)

    User (Old forums)
    Member
    Post count: 23064

    We have corrected this issue, you can obtain the latest version <a href=”http://download3.xceedsoft.com/Packages/3.0.7264.16200/XceedComponents.exe”>here</a&gt;.

    Thanks !

    Imported from legacy forums. Posted by Matt (had 5129 views)

    User (Old forums)
    Member
    Post count: 23064

    is there a new link to this file? i would like to check it out.

    Imported from legacy forums. Posted by Aran (had 2051 views)

    Diane [Xceed]
    Moderator
    Post count: 1353

    Hi Aran,

    You can find it on the following page:
    http://xceed.com/pages/TopMenu/Downloads/Updates.aspx?Lang=EN-CA

    However that package is from May 2007, I recommend downloading a more recent one instead.

    Imported from legacy forums. Posted by Diane [Xceed] (had 1650 views)

    User (Old forums)
    Member
    Post count: 23064

    Would you provide an updated link to this sample?  Thanks in advance!

    Imported from legacy forums. Posted by FinallyInSeattle (had 711 views)

    Diane [Xceed]
    Moderator
    Post count: 1353

    The link for the project sample has been fixed:
    http://forums.xceed.com/attach/WPF/DataGrid/TreeViewDataGrid.zip

     

    Imported from legacy forums. Posted by Diane [Xceed] (had 1079 views)

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.