Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wrap Kendo Grid Column

Kendo Grid columns is given as below. After doing zoom screen column is getting hide, I want to do wrap column. Can we do it by giving some propery on gridColumns. Please tell me. I am not able to find it. Here 'Your Occupation Details' is getting hide. Here are some more fields, I have given only three here.

 gridColumns: [
            {
                title: 'FirstName',
                field: 'FirstName',
                width: '0', hidden: true
            },
            {
                title: 'FirstName',
                field: 'FirstName',
                width: '250px'
            },
            {
                title: 'Your Occupation Details',
                field: 'OccupationDetails',
                width: '100',
            }]
like image 259
user1078749 Avatar asked Mar 04 '14 10:03

user1078749


4 Answers

Use headerAttributes to wrap long column names in the JS columns declaration as follows;

columns: [
{
  title: 'Your Occupation Details',
  field: 'OccupationDetails',
  width: '100',
  headerAttributes: { style: "white-space: normal"}
},
...
]

Or for strongly typed grids you can use HeaderHtmlAttributes in Columns as well.

columns.Bound(p => p.OccupationDetails).HeaderHtmlAttributes(
    new { style = "white-space: normal" }
);

Further documentation can be found in the Telerik's official forum Header Wrapping / Height and How to wrap kendo grid column

like image 165
Mahib Avatar answered Nov 14 '22 09:11

Mahib


You can set CSS properties of the Grid to enable column wrap.

.k-grid-header .k-header {
    overflow: visible;
    white-space: normal;
}

Take a look at this documentation for setting column header attributes.

http://docs.telerik.com/kendo-ui/api/web/grid#configuration-columns.headerAttributes

like image 20
IceMan Avatar answered Nov 14 '22 07:11

IceMan


This worked for me

.k-grid  .k-grid-header  .k-header  .k-link {
    height: auto;
}

and this

.k-grid  .k-grid-header  .k-header {
    white-space: normal;
}

source: http://www.telerik.com/forums/header-wrapping-height

like image 7
mxasim Avatar answered Nov 14 '22 07:11

mxasim


To wrap the header:

.k-grid .k-grid-header .k-header .k-link { height: auto; }

.k-grid .k-grid-header .k-header { white-space: normal; }

To wrap the rows:

td[role="gridcell"] { white-space: nowrap; }
like image 4
Ricardo França Avatar answered Nov 14 '22 09:11

Ricardo França