Asp.net mvc telerik电网中的电网运行
如何在网格中执行编辑和删除操作 我有下面的表格Asp.net mvc telerik电网中的电网运行,asp.net,asp.net-mvc,Asp.net,Asp.net Mvc,如何在网格中执行编辑和删除操作 我有下面的表格 <%=Html.Telerik().Grid(Model).Name("Grid").Columns(columns => { columns.Bound(m => m.Keywords); columns.Bound(m => m.Country).Title("Location"); columns.Bound(m => m.AreaID);
<%=Html.Telerik().Grid(Model).Name("Grid").Columns(columns =>
{
columns.Bound(m => m.Keywords);
columns.Bound(m => m.Country).Title("Location");
columns.Bound(m => m.AreaID);
columns.Bound(m => m.JobSearchAgentID).Hidden(false);
}).DataBinding(databinding =>
{
databinding.Server().Select("Agentlist", "Grid", new
{
ajax = ViewData["ajax"]
});
databinding.Ajax().Select("Agentlist",
"Grid").Enabled((bool)ViewData["ajax"]);
})
.DataKeys(keys =>
{
keys.Add(m => m.JobSearchAgentID);
}
)
.Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
.Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
.Pageable(paging => paging.Enabled((bool)ViewData["paging"]))
.Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
.Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
.Footer((bool)ViewData["showFooter"])
%>
<%}%>
{
columns.Bound(m=>m.Keywords);
columns.Bound(m=>m.Country).Title(“位置”);
columns.Bound(m=>m.AreaID);
columns.Bound(m=>m.JobSearchAgentID).Hidden(false);
}).DataBinding(数据绑定=>
{
databinding.Server()。选择(“代理列表”、“网格”,新建
{
ajax=ViewData[“ajax”]
});
databinding.Ajax().Select(“Agentlist”,
“网格”).Enabled((bool)ViewData[“ajax”]);
})
.DataKeys(keys=>
{
key.Add(m=>m.JobSearchAgentID);
}
)
.scrolling(scrolling=>scrolling.Enabled((bool)ViewData[“scrolling”]))
.Sortable(sorting=>sorting.Enabled((bool)ViewData[“sorting”]))
.Pageable(paging=>paging.Enabled((bool)ViewData[“paging”]))
.Filterable(filtering=>filtering.Enabled((bool)ViewData[“filtering”]))
.Groupable(分组=>grouping.Enabled((bool)ViewData[“grouping”])
.Footer((bool)视图数据[“showFooter”])
%>
有关Telerik MVC网格控制的所有信息
死链
以下是一个允许在网格中添加和编辑的网格示例:
<% Html.Telerik().Grid<ReportingPeriodGroupDto>()
.Name("ReportingPeriodGroupAdminGrid")
.DataKeys(keys => keys.Add(o => o.Id))
.Editable(editing => editing.Mode(GridEditMode.InLine))
.ToolBar(commands =>
{
commands.Insert();
})
.DataBinding(dataBinding => dataBinding.Ajax()
.Select("SelectReportingPeriodGroup", "Admin")
.Insert("InsertReportingPeriodGroup", "Admin")
.Update("UpdateReportingPeriodGroup", "Admin")
)
.Columns(columns =>
{
columns.Bound(o => o.ShortDescription).Width("10em").Width("8em");
columns.Bound(o => o.LongDescription).Width("20em");
columns.Command(commands => commands.Edit()).Title("Actions");
})
.Footer(false)
.Render();
%>
[AcceptVerbs(HttpVerbs.Post)]
[GridAction(GridName = "ReportingPeriodGroupAdminGrid")]
public ActionResult InsertReportingPeriodGroup()
{
ReportingPeriodGroupDto reportingPeriodGroupDto = new ReportingPeriodGroupDto();
TryUpdateModel(reportingPeriodGroupDto);
if (ModelState.IsValid)
{
reportingPeriodGroupDto.CreatedBy = UserId;
reportingPeriodGroupDto.CreatedDate = DateTime.Now.ToString();
ITransformer transformer = ServiceFinder.Instance.ServiceFactory.RedPortalTransformerFactory.GetTransformer(reportingPeriodGroupDto.GetType());
ReportingPeriodGroup parent = (ReportingPeriodGroup)transformer.Transform(reportingPeriodGroupDto);
RedPortalDbContext.ReportingPeriodGroups.Add(parent);
RedPortalDbContext.SaveChanges();
}
return SelectReportingPeriodGroup();
}
[AcceptVerbs(HttpVerbs.Post)]
[GridAction(GridName = "ReportingPeriodGroupAdminGrid")]
public ActionResult UpdateReportingPeriodGroup()
{
ReportingPeriodGroupDto reportingPeriodGroupDto = new ReportingPeriodGroupDto();
if (TryUpdateModel(reportingPeriodGroupDto))
{
reportingPeriodGroupDto.UpdatedBy = UserId;
reportingPeriodGroupDto.UpdatedDate = DateTime.Now.ToString();
ITransformer transformer = ServiceFinder.Instance.ServiceFactory.RedPortalTransformerFactory.GetTransformer(reportingPeriodGroupDto.GetType());
ReportingPeriodGroup parent = (ReportingPeriodGroup)transformer.Transform(reportingPeriodGroupDto);
RedPortalDbContext.ReportingPeriodGroups.Add(parent);
RedPortalDbContext.Entry(parent).State = EntityState.Modified;
RedPortalDbContext.SaveChanges();
}
return SelectReportingPeriodGroup();
}