Welcome to the Xceed Community | Help
Community Search  
More Search Options

Create Dynamic Columns via Collection in ViewModel

Sort Posts: Previous Next
  •  01-17-2011, 4:16 AM Post no. 29615

    Create Dynamic Columns via Collection in ViewModel

    Hi.

    I need my columns in my DataGridControl dynamically created via a collection in my viewmodel. Unfortunately I cannot bind the "Columns" property of the DataGridControl to an property in my viewmodel.

    How can I achieve this dynamic creation?

    greets

    Filed under: ,
  •  01-18-2011, 4:22 PM Post no. 29622 in reply to 29615

    Re: Create Dynamic Columns via Collection in ViewModel

    Hi Raphael,

    The best way would be to use the ItemProperty collection of the DataGridCollectionView instead to add/remove the columns you will want in your DataGrid.

    By default, the grid has AutoRemoveColumnsAndDetailConfigurations and AutoCreateColumns set to true. Those two need to stay at true for this to work well.

     


    ** Quick Tip: Clients with an active support subscription should be sending their questions by email if they wish to benefit from the faster response time. Thanks!


    Diane Lafontaine
    Technical Support
    Xceed Software Inc.
  •  01-19-2011, 2:32 AM Post no. 29626 in reply to 29622

    Re: Create Dynamic Columns via Collection in ViewModel

    Hi.

    Thanks for your reply.

    I used a DataGridCollectionView in an usual manner (as source for my grid) and had problems where the PropertyChanged event was not fired properly through this DataGridCollectionView when I edited a property. But I'll give it a try. 

    Any another suggestions are welcomed.

    greets

  •  01-20-2011, 12:19 PM Post no. 29646 in reply to 29626

    Re: Create Dynamic Columns via Collection in ViewModel

    Hi Raphael,

    This could be a change notifications issue. Jenny's blog post found at the following link is a good start:

    http://xceed.com/CS/blogs/dontpanic/archive/2009/04/01/i-notify-we-notify-we-all-wait-no-we-don-t.aspx

    Other than that, I'm not quite sure what could be causing the issue. If you have a small test project that reproduces it, we could look into it further. Simply send it by email to support@xceed.com and include a link to this forum thread for reference.



    ** Quick Tip: Clients with an active support subscription should be sending their questions by email if they wish to benefit from the faster response time. Thanks!


    Diane Lafontaine
    Technical Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.