Mus*_*faP 2 asp.net-mvc kendo-ui kendo-grid
可能吗?我尝试使用自定义列,但是我失败了,任何人都可以用剃刀给出一个简单的例子吗?
油漆工作:)
我想要这样的东西,列包括数据和一个按钮(带onclick)

//---Not Worked 1---
columns.Command(command =>
{
command.Custom("Telefonlar? Göster").Click("telefonlariGoster");
columns.Bound(x => x.Adres);
}).Width(580);
....
//---Not worked 2---
columns.Template(@<text>
<label>@item.Adres</label>
<input type="button" name="AdresGuncelle" value="AdresGuncelle" onclick="telefonlariGoster()" />
</text>);
//Worked
columns.Bound(x => x.Adres)
.ClientTemplate("#=Adres#" +
"<input type='button' class='telefonlariGoster' style='float: right;' name='telefonlariGoster' value='Telefonlar? Güncelle' onclick='telefonlariGoster()'/>");
Run Code Online (Sandbox Code Playgroud)
尝试使用要显示自定义列显示的列的ClientTemplate.例如:
@(Html.Kendo().Grid(Model)
.Name("grid")
.Columns(columns =>
{
columns.Bound(x => x.Name)
.ClientTemplate("#=Name#" +
"<input type='button' class='className' style='float: right;' name='buttonName' value='Click here' onclick='ButtonClick(\"#=Name#\", this)'/>");
columns.Bound(x => x.Id);
})
.DataSource(dataSource => dataSource
.Ajax()
.Total(10)
.ServerOperation(false)
)
)
Run Code Online (Sandbox Code Playgroud)
在脚本按钮单击功能
function ButtonClick(name, button) {
alert(name);
}
Run Code Online (Sandbox Code Playgroud)