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
close icon

DataProvider and ResizeToFit

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

2 Replies

PZ Peter Zaborski October 15, 2003 08:30 PM UTC

I forgot to mention, I am setting AllowResizeToFit = false; in my code. -Peter

AD Administrator 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).

Live Chat Icon For mobile
Up arrow icon