Dynamically Column width resizing

Hi
I am working on sfdatagrid, & have a small query regarding its width resizing dynamically.
In my sfdatagrid, i am having columns with datatemplate that consists of a border & textblock, 
this border in my datatemplate acts as a progress bar & is binded with a value, however what i would really is when my border width reaches 100% same as the column width, the width of column should increase & should show complete border, but rather it is hidden

I have tried with ColumnSizer="SizeToCells", but it did not work, 
I have applied resizing to true in sfdatagrid.

Can some one please help?

3 Replies

JG Jai Ganesh S Syncfusion Team March 20, 2018 12:50 PM UTC

Hi Nitin, 
You can achieve your requirement to resize the column width based on the cell content by using the below code, 
private void Sfgrid_Loaded(object sender, RoutedEventArgs e) 
{ 
    this.sfgrid.View.RecordPropertyChanged += View_RecordPropertyChanged; 
} 
 
private void View_RecordPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) 
{ 
    var column = sfgrid.Columns.FirstOrDefault(c => c.MappingName == e.PropertyName); 
 
    sfgrid.GridColumnSizer.ResetAutoCalculation(column); 
 
    sfgrid.GridColumnSizer.Refresh(); 
} 
 
UG Link: 
Regards, 
Jai Ganesh S 



AS aaron sulwer June 9, 2021 07:31 PM UTC

this example does not work

the event View_RecordPropertyChanged is never executed


VS Vijayarasan Sivanandham Syncfusion Team June 10, 2021 05:12 PM UTC

Hi aaron sulwer,

Thank you for contacting Syncfusion Support.

Based on provided information we have modify the sample and the reported issue “Dynamically Column width resizing” and unable to replicate the issue from our end. It is working fine as expected. Please find the tested sample and video demo from our end in the link below,

Sample Link:  https://www.syncfusion.com/downloads/support/forum/136541/ze/Sample-1269763138 
For more information related to RecordPropertyChanged event, please refer the user guide documentation,

UG Link: https://help.syncfusion.com/wpf/datagrid/data-binding#recordpropertychanged 
Please let us know if you have any concerns in this. 
Regards,
Vijayarasan S 


Loader.
Up arrow icon