Unable to view complete sentence when Grouping with GroupCaptionTextFormat

Hi, 

i am trying to look for simple solution to fix the display of GroupCaptionTextFormat. With my current font size and string length, some sentence is unable to view in full (rotate the phone may help but i wish to view the complete sentence in both angle). 

Can anyone provide examples on how to resolve the issue?  i.e. to perform word wrap or multiline for the group caption


Regards
Charles Wong

5 Replies

JA Jayaraman Ayyanar Syncfusion Team March 21, 2018 11:25 AM UTC

Hi Charles, 
 
Thanks for contacting Syncfusion support. 
 
We have checked your query. The query for the “Unable to view complete sentence when Grouping with GroupCaptionTextFormat”. Your requirement can be achieved by extending GridCaptionSummaryCellRenderer class to write the custom render where you need to set the LineBreakMode as WordWrap and then you will be able to see the whole text in the view when the text exceeds the view and it will comes to the next line. 
 
C# logics : 
public partial class MainPage : ContentPage 
    { 
        public MainPage() 
        { 
            
            InitializeComponent(); 
            dataGrid.CellRenderers.Remove("CaptionSummary"); 
            dataGrid.CellRenderers.Add("CaptionSummary", new GridCaptionSummaryCellRendererExt()); 
            dataGrid.GroupCaptionTextFormat = "{ColumnName} is Grouped by {Key} with Count- {ItemsCount} Items in the view"; 
 
        } 
    } 
 
    public class GridCaptionSummaryCellRendererExt : GridCaptionSummaryCellRenderer 
    { 
        public GridCaptionSummaryCellRendererExt() 
        { 
        } 
 
        public override void OnInitializeDisplayView(DataColumnBase dataColumn, SfLabel view) 
        { 
            base.OnInitializeDisplayView(dataColumn, view); 
            view.HorizontalTextAlignment = TextAlignment.Center; 
            view.BackgroundColor = Color.DarkCyan; 
            view.FontAttributes = FontAttributes.Bold; 
            view.FontSize = 18; 
            view.LineBreakMode = LineBreakMode.WordWrap; 
            view.TextColor = Color.White; 
        } 
    } 
 
 
  

We have also prepared the sample based on your requirement and you can download the same from the below link. 
 
Regards, 
Jayaraman. 



CW Charles Wong March 23, 2018 10:29 AM UTC

Hi Jayaraman. 

Thanks for your prompt response. Your sample is working perfectly but unfortunately it does not well integrate with my project

In my scenario, i did not set my SfDataGrid ItemsSource to bind with any object, instead, i create each table row manually. The problem arise when the "view" is still null at OnInitializeDisplayView, which, all the attempts to change the view value failed. May i know is there any alternative ? Perhaps you may suggest alternative events that i can apply the word wrap setting?

Attached here with the partial script of my project. Hope to hear from you soon.


Regards
Charles Wong

Attachment: syncfusionscenario_wordwrap_3fd46cbf.zip


JA Jayaraman Ayyanar Syncfusion Team March 26, 2018 07:35 AM UTC

Hi Charles,  
  
Sorry for the inconvenienced caused. 
  
We have checked your query for the “Unable to view complete sentence when Grouping with GroupCaptionTextFormat”. The provided solution is not suited for your case because you have not set LoadUIView as true while creating column in the grid in the given .CS file. We suspect that’s why this case is not worked in your project. Please set the LoadUIView as true in the GridColumn of DataGrid to get resolve this issue. 
 
Regards,    
Jayaraman.  



CW Charles Wong replied to Jayaraman Ayyanar March 26, 2018 09:25 AM UTC

Hi Charles,  
  
Sorry for the inconvenienced caused. 
  
We have checked your query for the “Unable to view complete sentence when Grouping with GroupCaptionTextFormat”. The provided solution is not suited for your case because you have not set LoadUIView as true while creating column in the grid in the given .CS file. We suspect that’s why this case is not worked in your project. Please set the LoadUIView as true in the GridColumn of DataGrid to get resolve this issue. 
 
Regards,    
Jayaraman.  


Hi Jayaraman

I really appreciate your willingness to assist and your excellent guidance to make my objective a success. 
Finally I can perform word wrap by extending GridCaptionSummaryCellRenderer class after set the LoadUIView as true.


Thanks and regards
Charles Wong



JA Jayaraman Ayyanar Syncfusion Team March 27, 2018 04:23 AM UTC

Hi Charles, 
 
Thanks for your feedback. 
 
We are happy to provide you the support. 
 
Regards, 
Jayaraman.  


Loader.
Up arrow icon