Summery Row columns dont stretch to needed width

how to make summery row columns stretch entire column??

is there a decimalaggregate too ?


6 Replies

SP Sreemon Premkumar Muthukrishnan Syncfusion Team August 23, 2024 06:32 PM UTC

Hi Klaus Aman,

There is not direct support to change the width based on the text in the Table summary. We are preparing the workaround to provide column width based on the table summary value. We need some to achieve this, and we will update you further details on or before August 27, 2024.

We appreciate your patience until then. 

Regards,

Sreemon Premkumar M.



SP Sreemon Premkumar Muthukrishnan Syncfusion Team August 27, 2024 04:12 PM UTC

Hi Klaus Aman,


We are almost in the final stage of preparing the workaround to provide column width based on the table summary value. We need some to achieve this, and we will update you further details on or before August 29, 2024.

We appreciate your patience until then. 


Regards,

Sreemon Premkumar M.



SP Sreemon Premkumar Muthukrishnan Syncfusion Team August 29, 2024 02:48 PM UTC

Hi Klaus Aman


Thank you for your patience.

We don't have direct support for sizing the column based on the TableSummary text. However, you can achieve this by overriding the GridColumnSizer class and calculating the size of the Summary text using the FormattedText. You can then return the modified size for the respective columns inside the CalculateHeaderWidth method. Please find the code snippet below.

Code snippet:

 protected override double CalculateHeaderWidth(GridColumn column, bool setWidth = true)

 {

     for (int i = this.DataGrid.RowGenerator.Items.Count - 1; i >= 0; i--)

     {

         if (this.DataGrid.RowGenerator.Items[i] is SpannedDataRow)

         {

             var spannedRow = this.DataGrid.RowGenerator.Items[i] as SpannedDataRow;

             foreach (var visibleColumn in spannedRow.VisibleColumns)

             {

                 if (visibleColumn.GridColumn.MappingName.Equals(column.MappingName))

                 {

                     var element = visibleColumn.ColumnElement as GridTableSummaryCell;


                     if (element.Content.ToString() != "")

                     {

                         Size SummaryTextSize = new Size(0, 0);

                         // The font size of the Text in the TableSummary is 14

                         SummaryTextSize = MeasureString(element.Content.ToString(), element.FontFamily, 14, element.FontStyle, element.FontWeight, element.FontStretch);

                         SummaryColumnSizes[visibleColumn.GridColumn.MappingName] = SummaryTextSize;

                     }

                     break;

                 }

             }

             break;

         }

     }


     double defaultWidth = base.CalculateHeaderWidth(column, setWidth);


     if (SummaryColumnSizes.ContainsKey(column.MappingName) && (defaultWidth < SummaryColumnSizes[column.MappingName].Width || SummaryColumnSizes[column.MappingName].Width != 0))

         return SummaryColumnSizes[column.MappingName].Width;

     else

         return defaultWidth;


 }


Image reference:


We have prepared a sample based on your requirement; please find it attached.


Regards,
Sreemon Premkumar M.


Attachment: SfDataGrid_FilterPopup_2081e7c6.zip


AP Alexa Perez September 11, 2024 09:50 AM UTC

Thank you so much for your help.



SP Sreemon Premkumar Muthukrishnan Syncfusion Team September 12, 2024 01:09 PM UTC

Hi Klaus Aman,

We are glad that the workaround meets your requirements. If you have any further questions, please don't hesitate to let us know.

Regards,
Sreemon Premkumar M.



JS Jayashree Suresh Anand Syncfusion Team September 13, 2024 06:55 AM UTC

Hi Alexa,  

You're welcome. Should you require additional assistance, please don't hesitate to let us know. For any new issues that may arise, feel free to open a new forum thread.

Regards,

Jayashree 


Loader.
Up arrow icon