我想设置其中一列kendo网格的宽度。 这里的简单代码:如何在绑定mvc后更改kendo网格列宽?
@(Html.Kendo()
.Grid<MyObject>()
.Name("Name")
.TableHtmlAttributes(new { style = "height: auto;" })
.Columns(c => {
c.Bound(m => m.ObjectId).Hidden();
c.Bound(m => m.Type).Title()
//Bound other fields
if (Model.Property)
{
c.Bound(m => m.Price).Title()
.HeaderHtmlAttributes(new {title = "Price"});
//Here I want to change the width of my first column
c.Container.Columns.Where(x => x.Title == "Type").FirstOrDefault.Width(200);
}
})
.Scrollable(src => src.Height(261))
.DataSource(ds => ds
.Ajax()
.Events(e => e.Error("app.ui.kendo.onGridError").RequestEnd("app.ui.project.onRequestEnd"))
.Read(r => r
.Action("Action", "Controller", new { Id = @Model.Id })
.Type(HttpVerbs.Get))))
的问题是,编译器说“的方法,委托或事件的预期”。绑定列后是否有另一种方法来改变宽度?
你为什么不直接改变它c.Bound(M => m.Type).title伪()。宽度(200)? – user5135401
@ user5135401因为我需要在if语句内部进行更改。 – user3818229