与有条件选择的行动剑道格列 [英] kendo grid column with conditionally chosen action
本文介绍了与有条件选择的行动剑道格列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的了:
columns.Bound(t => t.Id)
.Title("")
.Template(@<text></text>)
.ClientTemplate("<a class=\"k-button\" href='"
+ Url.Action("Edit", "Controller") + "/#=Id#'>Edit</a>")
.Width(110);
我需要的是根据类型的约束对象来选择一个特定的控制器动作。 (不同的形式,如 CarEdit
时,可以说键入== 1
和 PlaneEdit
在键入== 2
)
我已经做JS使用最近类似的事情(生产ClientTemplate内容),但没有讨厌的JS会大大AP preciate解决方案。
I've done similar thing using JS recently (to produce ClientTemplate content) but would greatly appreciate solution without nasty JS.
推荐答案
至于现在这是我最好的解决办法:
As for now this is my best solution:
columns.Bound(t => t.Id)
.Title("")
.Template(@<text></text>)
.ClientTemplate("#= GetEditTemplate(data)#")
.Width(110);
function GetEditTemplate(data) {
var html;
if (data.Type === 1) {
html = kendo.format("<a class=\"k-button\" href='" + '@Url.Action("Edit1", "Controller")' + "/{0}" + " '>Edit</a> ",
data.Id
);
}
else {
html = kendo.format("<a class=\"k-button\" href='" + '@Url.Action("Edit2", "Controller")' + "/{0}" + " '>Edit</a> ",
data.Id
);
}
return html;
}
这篇关于与有条件选择的行动剑道格列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文