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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid - setting width of each column

Thread ID:





115843 Feb 10,2014 11:15 AM UTC Feb 18,2014 05:52 AM UTC ASP.NET MVC (Classic) 1
Tags: Grid
Dikshit Gokhale
Asked On February 10, 2014 11:15 AM UTC


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

Abdul Matin M [Syncfusion]
Replied On 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


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon