Mr. T
Mr. T

Reputation: 4170

Kendo Grid MVC helper column AutoGenerate error

I've got a Kendo grid where I want to auto-generate the columns from the data source.

@(Html.Kendo().Grid(Model)
    .Name("Foo")
    .Columns(columns => columns.AutoGenerate(true)))

This works, but I want to set the columns to a fixed width so I'm trying to use this

@(Html.Kendo().Grid(Model)
    .Name("Foo")
    .Columns(columns => columns.AutoGenerate(action => { action.Width = 150; })))

I don't get any intellisense complains, but when I load the page I get a compile error

CS1660: Cannot convert lambda expression to type 'bool' because it is not a delegate type

Is this a known issue or am I doing something stupid?

Upvotes: 1

Views: 1811

Answers (1)

nemesv
nemesv

Reputation: 139778

The exception message is very misleading because the problem is that the GridColumnBase<T> (which is the type of your action) type's Width property type is string and you try to assign an int to it.

So you need to write:

@(Html.Kendo().Grid(Model)
.Name("Foo")
.Columns(columns => columns.AutoGenerate(action => { action.Width = "150px"; })))

Upvotes: 2

Related Questions