I have one requirement for asp.net MVC application and for that inside Kendo UI grid, i have customized one column with combo box and two buttons for performing adding or deletion of any user selected value or manual typed value from combo box control.
But i am not able to get how i can get button click information for any specific row of that column.
Kindly guide that how i can achieve such kind of behavior.
网格的示例代码如下,我希望可以点击类别列 .
@(Html.Kendo() . Grid() . Name("grid").Columns(columns => {columns.Bound(p => p.ProductName); columns.ForeignKey(p => p.CategoryID,(System.Collections) .IEnumerable)ViewData ["categories"],"CategoryID","CategoryName") . Headers ("Category").HtmlAttributes(new {@class = "templateCell"
}).ClientTemplate("<table cellspacing='0' class='data-row data-personal'><tr>" +
"<td>#=data.Category.CategoryName# <span class='custom-arrow k-icon k-i-arrow-s'></span></td>" +
"<td><button id='customButton'>Add</button> <span></span> <button id='customButton1'>Delete</button></td>" +
"</tr></table>")
.HeaderTemplate(
@<text>
<table cellspacing="0" class="data-header">
<tr>
<td colspan="2"><strong>Category</strong></td>
</tr>
<tr>
<td>Category Name</td>
<td>Settings</td>
</tr>
</table>
</text>
)
.Width(300);//.ClientTemplate("#=data.Category.CategoryName# <span class='custom-arrow k-icon k-i-arrow-s'></span>"); ;
columns.Bound(p => p.UnitPrice).Width(150);
columns.Command(command => command.Destroy()).Width(110);
})
.ToolBar(toolBar =>
{
toolBar.Save();
toolBar.Create();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Filterable()
.Groupable()
.Pageable()
.Scrollable()
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.PageSize(20)
.ServerOperation(false)
.Model(model =>
{
model.Id(p => p.ProductID);
model.Field(p => p.ProductID).Editable(false);
model.Field(p => p.CategoryID).DefaultValue(1);
})
1 回答
输入一些代码来帮助我们帮助您..
您需要在对象中包含要添加或删除的ID,
如果您创建了一个客户端模板,添加了两个特定按钮并调用了一个javascript函数,那么您可以访问该行的属性
例如:
编辑:
控制器:
视图
在您的客户端模板中: