We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

StDataGrid GridColumnSizer.Refresh

I have a columns that are GridTemplate columns with Custom Controls and Xamarin Forms Controls (Entry, etc.). If  I change the value of the Entry object, I fire an event and my SfDataGrid subscribces to this event change and attempts to Refresh the columns but fails. The columns do not resize.
The entry object itself seems like it is the same size.  I'm not sure if the Entry object itself has to resize and that in turn can trigger the column resizing.


My table column:
  GridTemplateColumn tableColumn = new GridTemplateColumn()
                        {
                            HeaderText = tableColumnDefinition.Header,
                            MappingName = mappingName,
                            LineBreakMode = LineBreakMode.WordWrap,
                            TextAlignment = TextAlignment.Center,
                            HeaderTextAlignment = TextAlignment.Center,
                            ColumnSizer = ColumnSizer.Auto
                        };

1 Reply

KK Karthikraja Kalaimani Syncfusion Team January 3, 2020 01:24 PM UTC

Hi Bobby,

Thanks for contacting Syncfusion support.

Your requirement can be achieved by refreshing the columns instead of refreshing the SfDataGrid on Value changed event of the Entry in GridTemplateColumn. We have prepared sample for the same.

Please refer the below code example,

 
[XAML]
…..
<syncfusion:GridTemplateColumn.CellTemplate> 
    <DataTemplate> 
                        <Grid>
<
Entry Text="{Binding Name}" TextChanged="Entry_TextChanged"></Entry> 
                        </Grid> 
                    </DataTemplate> 
 </syncfusion:GridTemplateColumn.CellTemplate>
…..

[.CS]
…..
private
void Entry_TextChanged(object sender, TextChangedEventArgs e) 
        { 
            if (e.OldTextValue != null && e.NewTextValue != null && e.NewTextValue != e.OldTextValue) 
            { 
//here grid.Columns[0] is the entry(Template column) column of SfDataGrid 
                grid.GridColumnSizer.ResetAutoWidth(grid.Columns[0]); 
                grid.GridColumnSizer.Refresh(); 
            } 
        }
…. 



Video link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Video_150324754275601.zip


We hope this helps, please let us know if need further assistance from us.

Regards,
Karthik Raja


Loader.
Live Chat Icon For mobile
Up arrow icon