This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
WpfElements 5.1.1563.21508 (9/25/2012 nightly build) If I programmatically add columns to the DataGrid.GroupedColumns collection before the DataGrid has painted the items, then when the DataGrid does paint all items are contained in a single group. If I use the mouse to drag the column into the grouping panel, then the items are grouped correctly. I am using DisplayMemberBinding. The Columns collection and ItemsSource have been set on the DataGrid prior to adding columns to the DataGrid.GroupedColumns collection. See the attached images to see the what's happening. Do you have any ideas or suggestions on how to resolve this issue? |
|
|
Hello Jared Thanks for pointing this out. This issue will be resolved in the next nightly build. Jason Fauchelle |
|
|
Hi Jason, I downloaded the latest nightly build (5.1.1566.21510), but I've run into a NullReferenceException with some of our DataGrids. Please see the attached image. I believe it is in the OnLoaded method in DataGrid.cs (line 77: DisplayedItemsSource.UpdateGrouping();). The DisplayedItemsSource is null. Thanks. |
|
|
Hello Jared Apologies for this sudden bug. This will be resolved in the next nightly build. Jason Fauchelle |
|
|
Jason, The bug was resolved, but the original issue still persists. I haven't had time to create a repro project yet, but there is still an issue with adding columns to the DataGrid.GroupedColumns collection programmatically before the DataGrid has painted. |
|
|
Hello Jared Don't worry about providing a repro, I believe I have reproduced this in the same way as you now. The issue is caused because the columns used by the DataGrid after it has loaded are not necessarily the same instances that you added to the Columns collection. These columns get cloned and added to the EffectiveColumns collection. I've noted this down to be improved in another version. One way to work around this is to attach an event handler to DataGrid.Loaded, then use a column from the EffectiveColumns collection for grouping instead of the Columns collection. Jason Fauchelle |
|
|
Jason, I've tried updating my code to add the columns into the DataGrid.GroupedColumns collection from the DataGrid.EffectiveColumns collection. The DataGrid.Loaded event is of no use to me currently, because I am using the same instance of the DataGrid and changing columns/data depending on the report the user selects. The columns for the report are generated in code through a converter. The snippet below may help you understand.
When a report is run, the DataGrid.ItemsSource (ReportItems collection) will be updated and I also clear and add columns into the DataGrid.GroupedColumns collection (now using the DataGrid.Effective columns). I'm still having the issue that all rows appear in the same group even though they have different values. If I visually (using the mouse) remove the grouped column and then add it back in (drag into the grouping panel using the mouse), then everything is grouped correctly on the screen. The DataGrid.Loaded event doesn't help me because the DataGrid is always visible and already loaded (even before any columns are added the first time). Hopefully this helps explain my situation a little better. Do you have any other suggestions or ideas? Thanks. |
|
|
Hello Jared To make this work, make sure you modify the GroupedColumns collection after you have made changes to the Columns collection and items source. I've tried this at my end with columns that use DisplayMemberBinding and it is working well. Jason Fauchelle |
|
|
I have tried modifying the GroupedColumns collection after setting the Columns collection and the ItemsSource. I still couldn't get the items grouped correctly until I forced the DataGrid to paint prior to modifying the GroupedColumns collection. Everything worked as expected after that (other than there is a small delay where the items are painted on the screen and then the screen changes when it repaints with the groupings). The following code should give you the basic idea of what I'm doing. The items are not grouped correctly unless I add the Application.DoEvents method call. I would really like to see this resolved as there is a delay due to the repaint and doesn't look very professional to the end user (the grid changing...grouping items). Hopefully, this will give you more of a clue as to what is happening. The grouping works just fine once the DataGrid has painted the items once. I'm not sure why, but that seems to be the case.
|
|
|
By the way, I seem to be struggling with the formatting of code when I post. The preview looks correct and I've made sure I have at least 4 spaces on the front of every line, but it seems to consolidate it to a single line when I actually post. Thanks. |
|
|
Hello Jared Thanks for the code snippet. I found the right combination of settings to reproduce this issue and have resolved this bug which you can update through the next nightly build. The code you posted looks fine at our end. Please let us know what web browser and the version number you are using. A screen shot of what you're seeing at your end would be useful too. Jason Fauchelle |
|
|
I'm glad you were able to reproduce the issue. It looks like the last nightly build was on the 9th. Should there be a more recent version? I'd love to get this correction soon. As for the code formatting issue when I post, I'm using IE 10.0.9200.16384 (Windows 8 Pro x64 RTM). I've attached images of both the preview and the resulting post. The preview looks as I'd expect, but the resulting post places all code on a single line. Thanks! |
|
|
Hello Jared Apologies for the missing nightly. The fix will be in the next nightly build instead. Thanks for the info about the forum post. I have reproduced this issue and have let our web team know about it. Jason Fauchelle |
|
|
Thank you! I appreciate all you guys do for us. |
|
|
Thanks for the fix Jason! It seems to work very well. |
|