2016-06-14 65 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 *模板,因爲它完成了客戶端不是*的一部分,結構*的部件,但部分數據。 –