Ticket Q584810
Visible to All Users

Generating Dynamic Columns

created 11 years ago

I am using dev express GridControl in my application to display data, GridControl itemsSource property is bound with ObservableCollection and columns are specified in xaml itself using below and AutoGenerateColumns property is set to None.

<dxg:GridControl.Columns>
<dxg:GridColumn>

We have one property in observablecollection which again is of List type and contains a list of items. So the requirement is to generate the columns for each element inside the list. The issue is the number of items in the list won't be constant so we will have to generate dynamic columns on the bases of items present in the list. Please help to provide some example showing how I can implement this using dev express grid.

Answers approved by DevExpress Support

created 11 years ago (modified 11 years ago)

Hi Ravinder,
If every row in your project can contain different count of nested items, it is necessary to handle every row and populate additional columns manually. I have prepared a sample demonstrating how to achieve this goal. Please take a look at the attached archive.

    Show previous comments (8)
    DevExpress Support Team 11 years ago

      Hi Ravinder,
      Thank you for the code snippet. It made things clearer.
      To achieve this goal, I suggest that you add the "[]" operator to the Order ViewModel. I have modified the sample to demonstrate this approach. Please review the Order class and the GridControl_CustomUnboundColumnData method.

      RS RS
      Ravinder Saini 1 11 years ago

        Thanks Alex its working perfectly fine

        DevExpress Support Team 11 years ago

          You are welcome, Ravinder.
          Feel free to contact us should you need further assistance

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.