我正在尝试使用控制器中设置的GridColumnSettings替换剃刀页面中的列网格定义。我遇到问题的选项是Fluent
columns.Bound(p => p.Freight).Width(250).Filterable(ftb => ftb.Cell(cell => cell.Operator("gte")));
GridColumnSettings中不可用的网格定义中可用的选项。如何在GridColumnSettings类中公开此功能?我这样做有两个原因;一种方法是使列的顺序动态化,并使Kendo网格的定义更容易。
public ActionResult ColumnSettings()
{
var columns = new[]
{
new GridColumnSettings
{
Member = "ProductName",
Width = "200px"
},
new GridColumnSettings
{
Member = "UnitPrice",
Width = "130px",
Format = "{0:c}",
},
new GridColumnSettings
{
Member = "UnitsInStock",
Width = "130px"
}
}
ViewData["Columns"] = columns;
return View(SessionProductRepository.All());
}
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.ProductViewModel>()
.Name("grid")
.Columns(columns => columns.LoadSettings((IEnumerable<GridColumnSettings>)ViewData["Columns"]))
.HtmlAttributes(new { style = "height: 380px;" })
.Scrollable()
.Groupable()
.Sortable()
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Product_Read", "Grid"))
)
)