1

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?

4

1 回答 1

2

异常消息非常具有误导性,因为问题是GridColumnBase<T>(这是您的action)类型的Width属性类型是string并且您尝试为其分配一个int

所以你需要写:

@(Html.Kendo().Grid(Model)
.Name("Foo")
.Columns(columns => columns.AutoGenerate(action => { action.Width = "150px"; })))
于 2013-09-19T17:01:30.330 回答