我有一个MVCContrib网格,显示来自Account对象的选定属性。我希望用户选择一行并将其带到另一个页面,以查看它们单击的行所代表的对象的完整属性。如何将一个.Selected动作添加到网格的行中?MVCContrib网格 - 选择行
3
A
回答
3
我今天刚刚遇到类似的问题。
可以使用.RowAttributes像这样:
Html.Grid(Model).Columns(column =>
{
column.For(e => e.Id);
column.For(e => e.Message);
})
.RowAttributes(x => new Dictionary<string, object>
{{"onClick", "window.location.href = 'google.com'"}})
.Render();
在因此,当您在点击它会触发JavaScript的“点击”,打开了谷歌。您可以通过使用Lamda中的“x”来更改网址以传入Id。
3
如果您使用网格在MVC3情况下,还可以通过在服务器端的扩展类实现这一点:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MvcContrib;
using MySolution.ViewModels;
namespace MySolution.Models.Extensions
{
public static class RowAttributeExtensions
{
public static Hash GetRowAttributes(this MySolution.ViewModels.Model)
{
string onclickFunctionBody = "{window.location.href = '/MyController/MyAction?id=" + Model.Id + "'; return false;}";
Hash hash = new Hash(onclick => onclickFunctionBody)
return hash;
}
}
}
,并在客户端,这将采取以下形式:
@Html.Grid(Model).RowAttributes(row => row.Item.GetRowAttributes()).Columns(column =>
{
column.For(c => c.Col1);
column.For(c => c.Col2);
...
})
相关问题
- 1. 执行行动后刷新MVCContrib网格
- 2. 将行添加到MVCContrib网格
- 3. 将Mvccontrib网格导出为excel
- 4. MVCContrib网格定制设计
- 5. MVCContrib网格分页定制
- 6. Mulitple MVCContrib网格1页
- 7. MvcContrib电网和复选框
- 8. Infragistics网格(行选择)
- 9. 奇选择行为网格
- 10. DHTMLX网格行选择
- 11. 具有MVCContrib的分层网格
- 12. MVCContrib网格 - 排序和分页
- 13. 如何设置header/alt。行/行样式为MvcContrib网格?
- 14. 有角度的网格标题行选择,选择所有行
- 15. Infragistics网格选择
- 16. ExtJS网格选择
- 17. MVCContrib网格 - 排序自定义列
- 18. JavaScript不能在mvccontrib网格中工作
- 19. MvcContrib网格和显示/编辑模板
- 20. 如何使用MVCContrib网格控件?
- 21. 使用Ajax的ASP.NET MVCContrib网格
- 22. 网格复选框选择
- 23. 的Silverlight 3.0网格行选择颜色
- 24. jQuery jqGrid - 网格行内的选择框
- 25. 从网格行选择不工作
- 26. 增强网格中的行选择
- 27. 用一行代码选择4x4网格
- 28. 自动选择数据网格行
- 29. 编辑时应选择kendo网格行
- 30. Extjs4,选择网格行和fireEvent rowClick?