DavidDunham
DavidDunham

Reputation: 1362

Kendo Grid columnShow / Hide does not redistibute widths

My example illustrates my problem (with comments): http://dojo.telerik.com/eyIHi

Problem explained here again:

Here is my code which is executed when the grid is built:

dataBound: function(e){
    e.sender.showColumn('ContactName');
},

I did not find a function to redistribute them like the grid does in the beginning (API here: http://docs.telerik.com/kendo-ui/api/javascript/ui/grid)

Upvotes: 1

Views: 1252

Answers (2)

DavidDunham
DavidDunham

Reputation: 1362

Auto fitting all columns after the change, then removing the set width from the grid reimposes their ability to strech relatively!

http://dojo.telerik.com/UyEfa

for(i=0;i<=self.sender.columns.length;i++){
    self.sender.autoFitColumn(i);
}
self.sender.element.find('table[role="grid"]').removeAttr('style');

Upvotes: 1

The Dread Pirate Stephen
The Dread Pirate Stephen

Reputation: 3169

If you want all your columns to distribute evenly across the grid width, don't specify a width for any of them. It does not sound like you want the columns to be 50px at all.

http://dojo.telerik.com/@Stephen/aRUGi

Also, the Kendo documentation explains why your 50px columns stretch to fill the entire grid despite explicitly setting them the 50px: http://docs.telerik.com/kendo-ui/controls/data-management/grid/appearance#column-widths. The paragraphs starting at "When all columns have pixel widths,..." is particularly relevent.

Upvotes: 0

Related Questions