- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 Telerik MVC 与动态 ExpandoObjects 的集合一起使用。
Controller 是:
[GridAction]
public ActionResult TestDiario()
{
var result = new List<dynamic>();
dynamic diarioModel = new ExpandoObject();
var dictionary = (IDictionary<string, object>)diarioModel;
dictionary.Add("ID", 1);
dictionary.Add("AlunoID", 12781);
dictionary.Add("DAY05CLASS1", true);
dictionary.Add("DAY05CLASS2", true);
dictionary.Add("DAY07CLASS1", true);
dictionary.Add("DAY08CLASS1", true);
result.Add(diarioModel);
return View(result);
}
@using Telerik.Web.Mvc.UI
@model IEnumerable<dynamic>
@{
ViewBag.Title = "TestDiario";
}
@(Html.Telerik().Grid(Model).Name("Grid")
.DataKeys(dataKeys => dataKeys.Add("ID"))
.Columns(columns =>
{
columns.Bound("MatAnoID").Visible(true);
columns.Bound("AlunoID");
columns.Bound("NroClasse");
columns.Bound("Aluno");
var dictionary = (IDictionary<string, object>)Model;
foreach (var property in (IDictionary<String, Object>)dictionary)
{
if (property.Key.ToString().Remove(3) == "DAY")
{
columns.Bound(property.Key);
}
}
})
.Pageable()
.Sortable()
.Groupable()
.Filterable()
)
1[System.Object]' to type 'System.Collections.Generic.IDictionary
2[System.String,System.Object]'。”}
最佳答案
是的,你可以,而且你很接近,但犯了一些错误。
1) Model 不是 IDictionary 类型,因为它不是 expando 对象。它是一个动态列表。
这有点小技巧,但为了解决这个问题,我只取了可枚举中的第一个(或默认)元素,然后从中制作了一个字典。
2) 您正在尝试绑定(bind)在您的 expando 对象中不作为属性存在的列。
我评论了那些。
3)我认为您正在寻找以“DAY”开头的键。如果您想从列名中删除“DAY”,您可以调整我的示例代码。
除此之外它工作正常:
@(Html.Telerik().Grid(Model).Name("Grid")
.DataKeys(dataKeys => dataKeys.Add("ID"))
.Columns(columns =>
{
//NOTE: some of these columns are not valid because you didn't include them as properties
//columns.Bound("MatAnoID").Visible(true);
//columns.Bound("NroClasse");
//columns.Bound("Aluno");
columns.Bound("AlunoID");
var first = Model.FirstOrDefault();
if (first != null) {
var dictionary = (IDictionary<string, object>)first;
foreach (var property in dictionary) {
string key = property.Key.ToString();
if (key.StartsWith("day", StringComparison.InvariantCultureIgnoreCase)) {
columns.Bound(property.Key);
}
}
}
})
.Pageable()
.Sortable()
.Groupable()
.Filterable()
)
关于asp.net-mvc - Telerik MVC 网格与 ExpandoObject 列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13371034/
我在使用 CodedUI 时遇到了 Silverlight 中选项卡的 telerik 控件的问题。我可以使用 CodedUI 记录我在选项卡中执行的操作,但是当我开始执行 CodedUI 测试时,它
我将网格与 Telerik 的“客户端选择”(http://demos.telerik.com/aspnet-mvc-beta/grid/selectionclientside) 一起使用,并且我的页
我知道我需要使用模板列,但我不清楚如何使用它。 我有一个返回集合的数据源,我可以将集合中的每个属性分配给一个列。 但是我该怎么做: 合并两列?如 col.prop1 +' '+ col.prop2 ?
我有一个 Telerik MVC 网格,其中包含一个 bool 值 CreateIncident。对于新行,我想将该值设置为 true。对于编辑,如果该值已经为真,我想禁用该复选框。剑道 UI 显然是
我使用的是 Telerik 的 RadGrid(RadGrid.Net2(我知道我应该升级到更新的版本,但这里不是一个选项..))。它的功能之一是将数据导出到 excel。使用 grid.Master
我在 asp .net 中创建了一个 telerik RadGrid。我的要求是为列标题提供我自己的颜色。我们怎样才能做到这一点...?下面是我正在使用的代码结构。
是否可以使用 Telerik MVC 扩展在链接标签上设置媒体属性 StyleSheetRegistrar方法? group .Add("telerik.common.css")
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 6年前关闭。 Improve thi
我在 Telerik MVC Grid 中有一个 DateTime 类型的列。我只想使用它的 Date 部分进行显示和过滤。结果,我使用了以下代码 @(Html.Telerik().Grid()
Xamarin 用 C# 编写模型 用每个操作系统自己的 native 方式编写 View Xamarin promise 在同一天添加库中的新功能 Telerik native 脚本 用 javas
我想在 TreeView 中选择子项时获取父项,并且还想查找所选节点是父节点还是子节点。 如果有人知道如何实现它,请告诉我。 提前致谢, 钦纳亚 最佳答案 为了获取所选节点,您需要使用 select事
我有一个使用自定义编辑模板的弹出编辑模式的radgrid。按下回车键后的编辑表单会将新项目插入网格。我进去添加一个项目。成功插入。然后我添加第二个项目:出现弹出窗口。我输入数据,然后按“输入”键插入项
我试图在预渲染事件中隐藏/显示嵌套telerik rad网格上的不同列,基于一个标志,但无论我将可见或显示属性设置为什么,它们都显示 这些是我的网格列:
我们如何删除以前在 Telerik RadGrid 上在 Post Back 上完成的数据排序。 最佳答案 将主表 View 的 SortExpression 设置为清除。 例子: _rdGrdRep
Telerik Rad Grid 中 ajax 完成事件的名称是什么?我尝试了文档中的内容,但出现以下错误 Parser Error Message: Type 'Telerik.Web.UI.Gri
我正在使用 Telerik 的 MVC 网格,并且我想提交带有一些超出网格值的批量编辑模式更改。根据这个telerik forum我可以调用网格的 submitChanges 函数并在 OnSubmi
我目前正在更改一个网站,该公司希望将所有内容从 Telerik 更改为 Kendo。 我现在遇到了一些麻烦。在 BindTo 方法中可以有一些映射,而 .ItemDataBound 。在那,你可以设置
有人知道更改 MVC 网格的 Telerik 扩展的高度的方法吗?除了使用 手动覆盖样式之外 div#MyGrid .t-grid-content { height: 100px !impor
我在我的 ASP.NET MVC 3 razor 应用程序中使用最新版本的 Telerik MVC 扩展。我还下载了最新版本的 jQuery。 我的 jQuery 文件与 Visual Studio
Telerik's Wiki 中似乎没有任何关于通过用于 MVC 的 Telerik Grid 的客户端 API 进行分组的文档。并且 Google 结果没有提供任何特定于客户端 api 和通过 ja
我是一名优秀的程序员,十分优秀!