Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Kendo Grid Column auto Width

Tags:

kendo-grid

I used jQuery plugin datatables, which will auto width columns to fetch the title or data content length if we don't specify the column width of the Grid.

Now I want the same function in Kendo Grid, however, I cannot find it except make Grid wrapper style fixed and set a col width css for all columns, which make the small length field also take big space.

So my question is how to make the Kendo Grid column (usually I have many fields, and it is scroll-able) auto width or in different length (and I don't expect to set width for each column manually).

Thanks

like image 715
cui Avatar asked Sep 02 '14 02:09

cui


1 Answers

You kind of have to set the width when you define the columns , if you don't specify the width then it will take the auto-width of the content. Take a look at this DOC http://docs.telerik.com/kendo-ui/api/web/grid#configuration-columns.width

columns: [
     { field: "name", width: "200px" },
     { field: "tel", width: "10%" }, // this will set width in % , good for responsive site
     { field: "age" } // this will auto set the width of the content 
   ],

If you need more ways to handle Kendo width, look at http://docs.telerik.com/kendo-ui/getting-started/web/grid/walkthrough#column-widths

like image 145
cwishva Avatar answered Jan 04 '23 11:01

cwishva