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
460
Style group by rows in xamdatagrid
posted

I have this xamdatagrid before grouping it looks like this

BeforeGrouping

And After I have grouped it looks like this

AfterGrouping

As you can see in the after group picture the lines are very hard to read. So how can I remove the texts and only show the digits and align the digits to there columns in grid and set a color around the digits, 

  • 2520
    Offline posted
    Hello Thomas,

     

    I have been looking into your question and found this forum thread, where you have recently addressed almost the same question. Based on your query there, I suppose that you would like to achieve the group-by appearance as shown in the second image there, is that so?

     

    Based on the provided images, I can infer that the WinForms’ UltraGrid has its DisplayLayout.Override.SummaryDisplayArea   property set to “InGroupByRows” and  DisplayLayout.Override.GroupBySummaryDisplayStyle property set to “SummaryCells”.

     

    The same can be achieved for the XamDataGrid by setting its FieldSettings object’s SummaryDisplayArea property to "InGroupByRecords " (from what I can see, this you have already done) and its FieldLayoutSettings object’s GroupBySummaryDisplayMode property to "SummaryCellsAlwaysBelowDescription".

     

    However, as you can read in the linked topic, the summary cells for this mode are located below the description, resulting in a higher group-by row, which may or may not fit your users’ requirements:

    If you would like to modify this behavior, my suggestion is to retemplate the default style of the GroupByRecordPresenter, as suggested in this forum thread and as shown in the below attached sample. There you will find a separate ResourceDictionary, containing the overridden styles. This modification is on line 257.  Nevertheless, do adopt this approach only if you are sure that the group-by row description will not overlap the summary cells, or you are not setting a SummaryDescriptionMaskInGroupBy on the FieldLayout object.

     

    Regarding coloring the summary values in the group-by row, this can also be achieved by modifying the default style, targeting the SummaryResultPresenter. In the sample, this is achieved by adding a DataTrigger, for when a parent with type “GroupBySummariesPresenter” is present. This is needed, so that the other summaries, positioned in the top/bottom of the grid (who are nested within a SummaryRecordContentArea object) do not obtain this color as well. This style can be found on line 29 in the Modified_GroupBySummaries_Styles.xaml file.

     

    Finally, the summary values can be formatted as demonstrated in this topic. The format will be applied for both the regular and group-by summaries. The sample shows how to show only the summary value.

     

    For the purposes of the example, in the sample there are three summary definitions added via code and the grid is grouped by one of its columns. Please, test it on your side and if you require any further assistance on the matter, please let me know.

     

    Sincerely,
    Bozhidara Pachilova
    Associate Software Developer
  • 2520
    Offline posted in reply to Thomas Kleist
    Hello Thomas,

     

     

    The height of the regular records’ rows can be modified by creating a style, targeting the DataRecordPresenter and setting its height property to some value:

     

                        <Style TargetType="{x:Type igDP:DataRecordPresenter}" >
                            <Style.Setters>
                                <Setter Property="Height"
                                        Value="20" />
                            </Style.Setters>
                        </Style>

    The height of the GroupBy rows can again be modified by tweaking the default style, targeting the GroupByRecordPresenter. My suggestion is to set a Height Property directly on this style. However, if setting it to a smaller value, you will notice the record appearing slightly cropped. This can be resolved by setting the same height value of the Grid with name PART_RecordContentSite in the GroupByRecordPresenter ControlTemplate. Additionally, as suggested by Andrew Smith in this forum thread, you could further tweak the SummaryRecordContentArea and SummaryRecordCellArea styles and modify their border thickness, so that the summaries within the GroupBy rows appear more centered after modifying the height.

     

    Below you will find a modified sample, demonstrating this approach. Please, refer to the Modified_GroupBySummaries_Styles.xaml file for the introduced style changes.

     

    Please, test the sample on your side and in case of any other questions, please let me know.

     

    Sincerely,
    Bozhidara Pachilova
    Associate Software Developer