2013-04-11 220 views
0

我在如何将行模板数据绑定应用到它上时遇到了问题。我不确定这样做的语法是什么。我正在使用服务器绑定模式。下面是我的代码Kendo UI Grid Grid模板

@(Html.Kendo().Grid((IEnumerable<IcmsViewModel.LookupView>)ViewData["LookupView"]) // Bind the grid to the Model property of the view 
    .Name("Grid") 
    .CellAction(cell => 
     { 

     if (cell.DataItem.Active == false) 
     { 
      cell.HtmlAttributes["style"] = "background-color: red"; 

     } 

     } 
) 
    .Columns(columns => 
    { 
     columns.Bound(p => p.LookupValue).ClientTemplate(" ").Title("Short Name").Width(300); 
     columns.Bound(p => p.Description).Width(300); 
     columns.Bound(p => p.Active).Width(300); 
     columns.Command(command => { command.Edit(); command.Destroy(); }); 

    }) 
**.RowTemplate(rows => 
       "<tr><td>Testing</td>" + 
     "<td colspan=\"2\"><input type=\"button\" name=\"ClickMe\" value=\"ClickMe\" onclick=\"javascript:window.open(('/Test/ViewTest'), 'ViewTest', 'height=' + (window.screen.height - 100) + ',width=200,left=' + (window.screen.width - 250) + ',top=10,status=no,toolbar=no,resizable=yes,scrollbars=yes');\"/></td>" + 
     "<td>Name</td></tr>" 
)** 
    .ToolBar(commands => commands.Create()) 
    .Groupable() 
    .Pageable() 
    .Sortable() 
    //.Filterable() 
    .Scrollable(x => x.Height(600)) 
    .Editable(editable => editable.Mode(GridEditMode.InLine)) 
     .DataSource(dataSource => dataSource 
      .Server() 
      .Model(model => { model.Id(p => p.Id); model.Field(p => p.Id).Editable(false); }) 
      .Create(create => create.Action("CreateLookup", "Icms")) 
      .Read(read => read.Action("Lookup", "Icms")) 
      .Update(update => update.Action("UpdateLookup", "Icms")) 
      .Destroy(destroy => destroy.Action("Destroy", "Sample")) 
     ) 

目前我硬编码在该行模板中的值,我如何与数据绑定在其数据库中,如果我想申请该行的模板。

.RowTemplate(行=> “p.LookupValue” + “” + “p.Description” )

请帮我在这,因为我是新来的剑道UI。非常感谢。

回答

6

你为什么不上列定义使用Template

.Columns(columns => 
{ 
    columns.Bound(p => p.LookupValue) 
      .Template(@<text>@item.LookupValue @item.Description</text>).Title("Short Name").Width(300); 
    columns.Bound(p => p.Active).Width(300); 
    columns.Command(command => { command.Edit(); command.Destroy(); }); 
}) 
+0

谢谢,现在的工作。 – user2268992 2013-04-11 08:52:15

+1

@ user2268992不要忘记接受这个问题作为你的问题的答案。 – 2013-04-11 11:23:35

+0

它不适合我,结果是空的。 我知道这很古老,但你能帮忙吗? – Star 2015-02-06 08:27:30