如何将模板添加到Kendo网格工具栏 [英] How to add a template to a Kendo grid toolbar
本文介绍了如何将模板添加到Kendo网格工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试向Kendo MVC网格添加自定义模板. 我的模板应包含2个内容
I am trying to add a custom template to Kendo MVC grid. My template should contain 2 things
- 创建按钮以将新记录添加到网格
- 自动完成框 过滤网格中的数据.
- Create button to add new record to the grid
- Autocomplete box to filter the data in the grid.
我正在尝试以下代码:
.ToolBar(toolbar =>
{
toolbar.Template(@<text>
<div class="toolbar">
<label class="category-label" for="category">Filter by name:</label>
@(Html.Kendo().AutoComplete()
.Name("employees")
.DataTextField("empName")
.Filter("contains")
.MinLength(3)
.Events(e => e.Change("nameChange"))
.DataSource(ds =>
{
ds.Read("FilteringList", "Employee");
})
)
</div>
</text>);
toolbar.Create().Text("New Record");
})
但是这不起作用.我只能看到自动完成框.
but this is not working. I can only see the autocomplete box.
关于如何满足要求的任何想法吗?
Any ideas on how I can accomplish my requirements?
推荐答案
删除以下行
toolbar.Create().Text("New Record");
从工具栏"部分添加,然后在模板内添加按钮. 请参见下面的代码:
from the ToolBar Section and add the button inside the template. Please see below code:
.ToolBar(toolbar =>
{
toolbar.Template(@<text>
<div class="toolbar">
<a class="k-button k-button-icontext k-grid-add" href="/YourControllerName/YouCreateActionResultJsonName?grdSearch-mode=insert">New Record</a>
<label class="category-label" for="category">Filter by name:</label>
@(Html.Kendo().AutoComplete()
.Name("employees")
.DataTextField("empName")
.Filter("contains")
.MinLength(3)
.Events(e => e.Change("nameChange"))
.DataSource(ds =>
{
ds.Read("FilteringList", "Employee");
})
)
</div>
</text>);
})
这篇关于如何将模板添加到Kendo网格工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文