【发布时间】:2015-10-07 13:03:29
【问题描述】:
我有一个剑道网格,我正在从System.Data.DataTable 动态构建。我在尝试锁定列时遇到问题。
我正在根据它们的标题将几列设置为锁定,正如您将在我的代码中看到的那样。布尔检查在预期的地方返回 true 或 false,并且该值在 .Locked() 属性中正确设置。但是网格没有锁定该列,也没有在列菜单中给我Lockable 选项。
请看我下面的代码:
@model MvcProject.UnitOfWork.ViewModels.Reports.FacilityEquipmentDistributionVm
@(Html.Kendo().Grid<dynamic>()
.Name("resultsGrid")
.Columns(columns =>
{
columns.Group(group => group
.Title("Facility Equipment Distribution Report : Date run - " + DateTime.Now.ToShortDateString())
.Columns(header =>
{
foreach (System.Data.DataColumn column in Model.CombinedTable.Columns)
{
string title = "";
bool showColumn;
if (Model.ColumnTitles.TryGetValue(column.ColumnName, out title))
{
}
else
{
title = column.ColumnName;
}
if (Model.ColumnsToShow.TryGetValue(column.ColumnName, out showColumn))
{
}
else
{
showColumn = false;
}
bool lockColumn = (title == "PropertyRef" || title == "PropertyName" || title == "Address" || title == "Prefix" || title == "Floor");
header.Bound(column.ColumnName)
.Title(title)
.Visible(showColumn)
.Locked(lockColumn)
.Lockable(true)
.Width(title.Length * 8);
}
})
);
})
.HtmlAttributes(new { style = "height: 900px;" })
.Pageable(p => p
.ButtonCount(5)
.PageSizes(true)
.Refresh(true)
)
.Scrollable(s => s.Height("auto").Enabled(true))
.Sortable()
.Reorderable(reorderable => reorderable.Columns(true))
.Filterable()
.Groupable()
.ColumnMenu()
.Resizable(r => r
.Columns(true)
)
.Excel(excel => excel
.FileName("Facility Equipment Distribution.xlsx")
.Filterable(true)
.ProxyURL(Url.Action("_GridExportSave", "Reports"))
.AllPages(true)
)
.DataSource(d => d
.Ajax()
.Read(read => read.Action("_FacilityEquipmentDistributionResults_Read", "Reports").Data("Genesis.Reports.Space.Search.getPaginationData"))
.ServerOperation(true)
.PageSize(20)
)
.ToolBar(tools =>
{
tools.Pdf();
tools.Excel();
})
//PDF removed for now until it is patched
.Pdf(pdf => pdf
.AllPages()
.FileName("FacilityEquipmentDistribution.pdf")
.ProxyURL(Url.Action("_GridExportSave", "Reports"))
)
//.Events(events => events.DataBound("Genesis.Reports.Space.Search.loadTT"))
)
任何帮助将不胜感激。
亲切的问候,
加雷斯
【问题讨论】:
-
我遇到了类似的事情,当使用
Grid<dynamic>()时,.Columns(columns =>下的代码似乎对 gird 没有影响。详细问题在这里stackoverflow.com/questions/37437363/…。谢谢队友
标签: c# asp.net-mvc kendo-ui kendo-grid kendo-asp.net-mvc