The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I am using a DataBoundGrid and populating it via the DataProvider property. I've implemented my own data provider. This works fine as far as the grid displaying the correct data values.
However, it seems I can't resize the cells (col widths specifically) because if I call grid.Model.ColWidths.ResizeToFit this call gets executed BEFORE the calls for data to the data provider, ie. the grid's cell values are all "" and thus the col widths never get set correctly!
Is there a way to use a data provider mechanism to populate the grid and still be able to use the ResizeToFit function?
Or is there some better way to do what I am trying to do?
Note that I'm using the DataProvider mechanism becuase my attempts at using data binding were not successful (to do what I need).
-Peter
I forgot to mention, I am setting
AllowResizeToFit = false;
in my code.
-Peter
ADAdministrator Syncfusion Team October 16, 2003 08:08 AM UTC
The grid.Model.ColWidths.ResizeToFit is purely a functional call. It will size the columns according to the data in the columns at the time of the call. There is no way around that.
So, after your dataprovider has been instantiated and has access to its data store, and after you have set this dataprovider to the DataProvider property of the grid, then if you call ResizeToFit, the grid should have access to the data it needs to do the sizing. Does this not work for you?
Is there no way for you to call the ResizeToFit method after the data is available?
Another thing you can do is to explicitly set the grid.Model.ColWidths[row] values to something yourself. This you can do without the grid having access to the actual data (though it would need access to the proper column count that might be part of your dataprovider).