2016-06-14 61 views

回答

2

我不认为你可以使用x-剑道-template阻止服务器端,因为它们在使用前通过kendo中的kendo.template()实际“编译”为kendo模板。

但是你可以做的是包括在网格中的工具栏模板的详细剃刀:

.ToolBar(t => t.Template(@<text> 
    @(Html.Kendo().ToolBar() 
     .Name("toolbar") 
     .Items(items => 
     { 
      items.Add().Type(CommandType.Button).Text("X").Id("X"); 

      items.Add().Type(CommandType.Button).Text("Y").Id("Y"); 
     }) 
    ) 
</text>)) 

或者

.ToolBar(t => t.Template(Html.Partial("_ToolBar").ToHtmlString())) 

或任何剃刀代码,你要使用。

+0

Thx到目前为止! ..但我没有真正明白你的观点我认为:我不想使用x-kendo-template服务器端,但我想在我的Kendo工具栏中引用它,以便它使用它。 x-kendo-template本身是cshtml文件中包含的java脚本块。我已经看到类似于这样的例子:@view(Model) .Name(“ownerOfferingPreview”) .TagName(“div”) .ClientTemplateId(“ownerOfferingTemplate”)'where _ownerOfferingTemplate_指的是js x-kendo-template –

+1

模板和ClientTemplateId不一样,如果你想用Stephen的话来说就是使用剃须刀。http://www.telerik.com/forums/load-toolbar-template-from -x-kendo-template –

+0

对不起,我以为你想要一个服务器端解决方案,因为这是.Template()方法的用途。我不相信你可以渲染Grid/ToolBar服务器端的* part *和另一部分客户端。您可以在ListView(和网格列定义)上使用.ClientTemplateId()的原因是,当每个项目/单元格被渲染完成时,使用* that *模板,因为它完成了客户端不是*的一部分,结构*的部件,但部分数据。 –