Telerik MVC3 Razor 批量编辑网格时出现客户端模板问题
我正在使用带有 ASP.Net MVC3 Razor 视图的 Telerik MVC Batch 可编辑网格。除了使网格可编辑之外,我还尝试添加一个带有编辑链接的列(最好是可链接的图像),单击该链接将进入单个记录的编辑页面。例如 -
@(Html.Telerik().Grid(Model)
.Name("BillersGrid")
.DataKeys(keys => keys.Add(o => o.id))
.ToolBar(commands =>
{
commands.Insert();
commands.SubmitChanges();
})
.DataBinding(databinding =>
{
databinding.Ajax()
.Select("SelectBatchEditing", "BillerAdmin")
.Update("SaveBatchEditing", "BillerAdmin", new { id = (string)ViewData["BillerSearchString"] });
}
)
.Columns(columns =>
{
columns.Command(commands => commands.Delete().ButtonType(GridButtonType.BareImage)).Width(10).Title("");
columns.Bound(o => o.id).Title("Edit").ClientTemplate("<a href='/BillerAdmin/EditBiller?id=<#=id#>'>Edit</a>");
columns.Bound(o => o.id).Hidden(true);
columns.Bound(o => o.CouponBillerName).Title("Coupon Biller Name").HtmlAttributes(new { style = "white-space:nowrap;" });
columns.Bound(o => o.PayeeRecipient).Title("Recipient").HtmlAttributes(new { style = "white-space:nowrap;" });
columns.Bound(o => o.PayeeAddress1).Title("Address 1").HtmlAttributes(new { style = "white-space:nowrap;" });
columns.Bound(o => o.PayeeAddress2).Title("Address 2").Width(100);
columns.Bound(o => o.PayeeCity).Title("City").HtmlAttributes(new { style = "white-space:nowrap;" });
columns.Bound(o => o.State).ClientTemplate("<#= State #>");
columns.Bound(o => o.PayeeZip).Title("Zip").Width(50);
columns.Bound(o => o.PayeeZipPlusFour).Title("Zip+4").Width(50);
columns.Bound(o => o.Category).ClientTemplate("<#= Category #>").HtmlAttributes(new { style = "white-space:nowrap;" });
columns.Bound(o => o.AccountNumberFormat).Title("Account Number Format").Width(50);
columns.Bound(o => o.CodeLineNumberFormat).Title("CodeLine Number Format").Width(50);
})
.Pageable(paging => paging.Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPreviousAndNumeric).Total((int)ViewData["BillersCount"]).PageSize(50))
.EnableCustomBinding(true)
.Editable(editing => editing.Mode(GridEditMode.InCell))
.Sortable()
.ClientEvents(evt => evt.OnDataBinding("BillersGrid_onDataBinding"))
.KeyboardNavigation(config => config.EditOnTab(true))
.HtmlAttributes(new { style = "font-size:.9x cem;" })
)
这有效。但问题是网格在第一次渲染时会显示 Id(这是一个 GUID)。在分页时,“编辑”超链接正确显示。
有人可以帮助我吗?我希望网格每次都显示编辑链接。该单元格应该是不可编辑的,并且应该是指向另一个视图的超链接。该功能工作正常。问题是 ID 在第一次渲染时显示。 请帮忙。
谢谢, SDD
I am using a Telerik MVC Batch editable grid with ASP.Net MVC3 Razor views. In addition to having the grid to be editable I am also trying to add a column with an Edit link (ideally a linkable image), clicking on which will lead me to an edit page for the individual record. Eg -
@(Html.Telerik().Grid(Model)
.Name("BillersGrid")
.DataKeys(keys => keys.Add(o => o.id))
.ToolBar(commands =>
{
commands.Insert();
commands.SubmitChanges();
})
.DataBinding(databinding =>
{
databinding.Ajax()
.Select("SelectBatchEditing", "BillerAdmin")
.Update("SaveBatchEditing", "BillerAdmin", new { id = (string)ViewData["BillerSearchString"] });
}
)
.Columns(columns =>
{
columns.Command(commands => commands.Delete().ButtonType(GridButtonType.BareImage)).Width(10).Title("");
columns.Bound(o => o.id).Title("Edit").ClientTemplate("<a href='/BillerAdmin/EditBiller?id=<#=id#>'>Edit</a>");
columns.Bound(o => o.id).Hidden(true);
columns.Bound(o => o.CouponBillerName).Title("Coupon Biller Name").HtmlAttributes(new { style = "white-space:nowrap;" });
columns.Bound(o => o.PayeeRecipient).Title("Recipient").HtmlAttributes(new { style = "white-space:nowrap;" });
columns.Bound(o => o.PayeeAddress1).Title("Address 1").HtmlAttributes(new { style = "white-space:nowrap;" });
columns.Bound(o => o.PayeeAddress2).Title("Address 2").Width(100);
columns.Bound(o => o.PayeeCity).Title("City").HtmlAttributes(new { style = "white-space:nowrap;" });
columns.Bound(o => o.State).ClientTemplate("<#= State #>");
columns.Bound(o => o.PayeeZip).Title("Zip").Width(50);
columns.Bound(o => o.PayeeZipPlusFour).Title("Zip+4").Width(50);
columns.Bound(o => o.Category).ClientTemplate("<#= Category #>").HtmlAttributes(new { style = "white-space:nowrap;" });
columns.Bound(o => o.AccountNumberFormat).Title("Account Number Format").Width(50);
columns.Bound(o => o.CodeLineNumberFormat).Title("CodeLine Number Format").Width(50);
})
.Pageable(paging => paging.Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPreviousAndNumeric).Total((int)ViewData["BillersCount"]).PageSize(50))
.EnableCustomBinding(true)
.Editable(editing => editing.Mode(GridEditMode.InCell))
.Sortable()
.ClientEvents(evt => evt.OnDataBinding("BillersGrid_onDataBinding"))
.KeyboardNavigation(config => config.EditOnTab(true))
.HtmlAttributes(new { style = "font-size:.9x cem;" })
)
This works. But the issue is that the grid is displayed with the Id (which is a guid) the first time it is rendered. On paging the "Edit" hyperlink is correctly shown.
Can some one help me. I would like the grid to show the Edit link every time. This cell should be non editable and should be a hyperlink going to another view. The functionality works correctly. The issue is the ID gets displayed the first time it is rendered.
Please help.
Thanks,
SDD
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
客户端模板在 ajax 绑定期间应用。您的网格最初是在服务器端绑定的:
也可以设置服务器端模板:
或者使用 ajax 使网格最初绑定:
Client templates are applied during ajax binding. Your grid is initially bound server-side:
Either set a server-side template as well:
or make the grid initially bound using ajax: