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

Grid - setting width of each column


We are using Syncfusion grid and binding data source with view data as below. I want to set width for each column. The data contained in view data is dynamically generated and varies. In such scenario how can we set the width of each column? Please help.

                        .Datasource((System.Data.EnumerableRowCollection)ViewData["vwdta_" + str])
                        .EnablePaging().PageSettings(p => p.PageSize(pagesize))
                        .ClientSideEvents(c=>c.OnActionBegin("Begin"))  )

Thank you

1 Reply

AM Abdul Matin M Syncfusion Team February 18, 2014 05:52 AM UTC

Hi Dikshit,


Thanks for your interest in Syncfusion products.


We have analyzed your requirement and it can be achieved by iterating each column and we can set the width for each column dynamically. Please refer the below code snippet.


.Column(cols =>


        if ((HttpContext.Current.Session["datasource"] as DataTable) != null)


            System.Data.DataTable dataTable = (HttpContext.Current.Session["datasource"] as DataTable);

            foreach (System.Data.DataColumn col in dataTable.Columns)






For your convenience we have prepared a simple sample based on the code snippet you have provided and the same can be downloaded from the link below.


Please use the sample and get back to us if you have any other queries.


Please let us know if you need any further assistance.



Abdul Matin M

Attachment: SetWidthSample_c87dd3cb.zip

Live Chat Icon For mobile
Up arrow icon