Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
250
Datagrid dynamic columns and formatting
posted

Hi team

I need to render a XamDataGrid in my WPF application where certain columns are dynamic in nature. the number of such columns may vary depending on the data in the database.

Such columns should have a common group heading. Please refer to below columns in the excel

Month
September December March Specialcase

The number of rows are also not know before hand.

Also certain rows are disabled on possibly a hidden column value. The rows in dark.

Certain cells should be shaded out as necessary

We use MVVM in our project and avoid using code behind wherever possible.

Negative numbers are displayed in red with brackets indicating that there is formatting to be applied

Below is the exact of the grid required.

Request you to please suggest how the below requirement can be achieved.

YTD  TEST Month Total Sub-Total Allocated
AMOUNT Preference September December March Specialcase Distributions   Amount  
Fixed Assets                      
land                         -   Y                         -                            -                         -                         -                         -                         -                         -   1                       -  
buildings                         -   Y                         -                            -                         -                         -                         -                         -                         -   1                       -  
machinery 6,601.77 Y                         -                            -                         -                         -                         -                         -   6,601.77 1                       -  
furniture 2,806.81 Y                         -                            -                         -                         -                         -                         -   2,806.81 1                       -  
tools 9,764.88 Y                         -                            -                         -                         -                         -                         -   9,764.88 1                       -  
real estate                         -   Y                         -                            -                         -                         -                         -                         -                         -   1                       -  
vehicles 9,450,891.35 Y                         -                            -                         -                         -                         -                         -   9,450,891.35 1                       -  
                       
Intangible Assets                      
goodwill                         -   Y                         -                            -                         -                         -                         -                         -                         -   1                       -  
copyrights                         -   Y                         -                            -                         -                         -                         -                         -                         -   1                       -  
                       
Total assets 9,470,064.81                           -                            -                         -                         -                         -                         -   9,470,064.81                         -  
Cash Distribution                      
TIC 10.00   20.00 30.00 40.00 50.00 60.00 70.00 80.00   90.00
Less TGC (2,806.81)                           -                            -                         -                         -                         -                         -   (2,806.81)                         -  
Net Cash Distr (2,796.81)   20.00 30.00 40.00 50.00 60.00 70.00 (2,726.81)   90.00
                       
Other Distribution Amounts                      
Other Non-Assessable Amounts 2,222.00 N                         -                            -                         -                         -                         -                         -   2,222.00 4                       -  
Return of Capital                         -   N                         -                            -                         -                         -                         -                         -                         -   4                       -  
TAP 1,105.60 N                         -                            -                         -                         -                         -                         -   1,105.60 3                       -  
NTAP 1,020.80 N                         -                            -                         -                         -                         -                         -   1,020.80 3                       -  
Cash Adjustments                         -                                -                         -                         -                         -                         -                         -      
Total Other Distribution Amounts 4,348.40                           -                            -                         -                         -                         -                         -   4,348.40                         -  
                       
Total Cash Distribution 1,551.59   20.00 30.00 40.00 50.00 60.00 70.00 1,621.59   90.00

Parents
  • 34430
    Offline posted

    Hello Manesh,

    There are a few ways that I could see that you could achieve your requirement with the XamDataGrid, and in these ways, one thing that would remain consistent is the "field grouping" functionality that you are looking for regarding your "month" fields that you have listed. To achieve this part, you could utilize the Field Grouping feature that was added in the 16.1 version of the WPF product. You can read about Field Grouping in our online documentation, here: http://www.infragistics.com/help/wpf/xamdatagrid-field-grouping.

    The negative number formatting could be achieved using a Style for CellValuePresenter and a converter. I would recommend that you see the following blog post regarding CellValuePresenter conditional formatting: http://www.infragistics.com/community/blogs/alex_fidanov/archive/2010/01/12/howto-using-wpf-converters-to-style-the-xamdatagrid.aspx.

    The other parts that you are looking to achieve would really depend on how exactly you want your page layout to look and behave. From the way that you have presented your data, I see a couple of different options that you could go with. For one, you could create a single grid with all of the data that you have listed inline, but this would be the most complex, and most difficult way, as it would require quite a bit of styling and inclusions of identifiers for which rows are "header" rows (i.e. "Fixed Assets, Cash Distribution, etc.) and whether or not rows are distribution amounts or assets, which would mainly be for the "N" and "Y" formatting that you wish to have applied. Another challenge that you may face by placing this entirely in a single grid inline would be getting your summaries in place, as you would likely have to calculate this manually if you used a single inline grid.

    Instead of using a single inline grid, I would recommend that you do one of two things. The first is to group the header rows. In other words, you would have a separate column that contains what the header should be, and you could group by this column. This would allow you to use the built-in summary functionality for the XamDataGrid to calculate the summary "bands" for each of the groups. It would also create a sort of hierarchical view for you, which you could also use as a structure for your data, but I believe this would be more complex than the grouping option.

    Another thing you could do is use multiple grids. This would make the "N" and "Y" formatting easier, as you would be able to write styles local to each grid, and then perhaps you could have a separate label that returns the "Total" for that particular grid or category. Using multiple grids, you could also do the grouping mentioned above.

    If you would like, I can create you a sample project demonstrating some of these ways, but if you could please provide some information on the layout that you are looking for in your application, this would give me a good starting point so that I may create a sample project and provide you more information on exactly what you could do to achieve this dynamic scenario.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

Reply Children