0
我需要將一個列名或值'none'傳遞給我的kendo網格,以根據Viewbag元素的值對其進行有條件分組。當我按預期傳遞組名稱時,我的問題是這樣做是否值「無」中通過分組,我有代碼:如何根據Viewbag值條件分組或不分組KendoUI網格
@(Html.Kendo().Grid<dynamic>()
.Name("exportGrid")
.DataSource(dataSource =>
{
dataSource.Ajax()
.Read("ReadGrid", "Report", new { id = Model.Inquiry_ID })
.Group(grp => grp.Add(ViewBag.groupBy, typeof(string)))
.Model(m =>
{
// Add the fields to the dynamic model
foreach (var field in Fields)
{
switch (field.DATA_TYP_NUM)
{
case 1: m.Field(field.INTERNL_NME, typeof(string)); break;
case 2: m.Field(field.INTERNL_NME, typeof(double?)); break;
case 3: m.Field(field.INTERNL_NME, typeof(double?)); break;
case 4: m.Field(field.INTERNL_NME, typeof(DateTime?)); break;
}
}
})
.ServerOperation(true);
})
.Groupable()
.Filterable()
.Sortable()
.ColumnMenu()
.Events(e => e.DataBound("onDataBound"))
.Resizable(resize => resize.Columns(true))
.Columns(columns =>
正如我所說的 - 這工作得很好,但我需要一種方法來當Viewbag.groupBy == "none"
排除.Group(....)
條款。
謝謝 - 那工作! – MikeD 2013-04-25 15:59:39