2014-01-23 59 views
1

我有一个Telerik MVC电网单详细视图Telerik Tabstrip内部没有显示Telerik Grid

内详细视图telerik tabstrip。当我选择要显示的网格行时,细节将完全打开。

我抄网格外的标签栏代码,改变网格的名称为静态的名字和来呈现网格而不是其输出作为htmlstring的,它显示完美。

我试过注册所有必需的javascript文件,没有改变。

在这一点上,我很难过。我清除了整个标签条,所以它只包含文本,但没有更改。

这里是我所代码:

<%: Html.Telerik().Grid(Model.AccessRequests) 
    .Name("gridAccessRequests") 
    .ColumnContextMenu() 
    .DataKeys(d => { d.Add(a => a.Access_Request_ID).RouteKey("id");}) 
    .DataBinding(dataBinding => dataBinding    
     .Ajax()     
      .Select("AjaxBinding", "Home")    
      .Insert("Insert", "Home")     
      .Update("Save", "Home")     
      .Delete("Delete", "Home")) 
    .ToolBar(commands => commands.Insert()) 
    .Editable(editing => editing 
     .InsertRowPosition(GridInsertRowPosition.Bottom) 
     .Mode(GridEditMode.PopUp)) 
    .HtmlAttributes(new { style = "width:100%" }) 
    .Selectable() 
    .Sortable(sorting => sorting    
     .OrderBy(sortOrder => sortOrder.Add(o => o.EMPLOYEE_NAME).Ascending())) 
    .Filterable(filtering => filtering    
     .Filters(filters => filters     
      .Add(o => o.RECORD_YEAR).IsEqualTo(Model.CurrentYear)))         
    .Pageable(paging =>    
     paging.PageSize(15)     
     .Style(GridPagerStyles.NextPreviousAndNumeric)     
     .Position(GridPagerPosition.Both)) 
    .ClientEvents(events => 
     { 
      events.OnEdit("onEdit"); 
      events.OnRowDataBound("requests_onRowDataBound"); 
     }) 
    .DetailView(details => details.ClientTemplate(
     Html.Telerik() 
      .TabStrip() 
      .Name("TabStrip_<#=id#>") 
      .SelectedIndex(0) 
      .Items(items => 
      { 
       items.Add().Text("Assets").Content("Assets"); 
       items.Add().Text("Locations").Content("Locations");              
      }) 
      .ToHtmlString() 
    ))               
    .Columns(col => 
     { 
      col.Bound(c => c.Access_Request_ID).Title("ID"); 
      col.Bound(c => c.RECORD_YEAR).Title("Year"); 
      col.Bound(c => c.VERSION_NO).Title("Version"); 
      col.Bound(c => c.EMPLOYEE_NAME).Title("Name"); 
      col.Command(commands => 
      { 
       commands.Edit() 
        .ButtonType(GridButtonType.Image); 
       commands.Delete() 
        .ButtonType(GridButtonType.Image); 
       commands.Custom("Clone")// the constructor accepts the name of the custom command (used to differentiate between multiple custom commands)      
        .Text("Clone")      
        // Specify which fields from the bound data item to include in the route (pass as action method arguments)      
        .DataRouteValues(route => route.Add(o => o.Access_Request_ID).RouteKey("requestId"))      
        .Ajax(true)      
        // Which action method to call      
        .Action("CloneRequest", "Home"); 
      }).Width(145) 
      .IncludeInContextMenu(false); 

    })%> 

这里是独立的标签栏:

<% 
Html.Telerik().TabStrip() 
    // Make the Name unique 
    .Name("TabStrip") 
    .SelectedIndex(0) 
    .Items(items => 
    { 
     items.Add().Text("Assets").Content("Assets"); 
     items.Add().Text("Locations").Content("Locations"); 
    }) 
    .Render(); 
%> 

任何建议/解决方案/演示会有所帮助。

提前致谢!

UPDATE

我已想出了tabstrips不显示网格上的初始载荷;在点击网格的刷新按钮或分页后,条形标签显示并正常工作。

似乎有一个无效的属性值错误是在网格加载后,但在任何数据绑定完成之前抛出,但我仍然无法找到确切的问题。再次,点击网格的刷新按钮或分页将成功绑定所有行。

回答

1

页面首次加载时,网格通过服务器端绑定加载。标签条在客户端模板中定义,在服务器绑定期间不使用。刷新网格时,通过ajax绑定加载,并使用客户端模板。

您需要首先通过ajax绑定来加载网格,因此您需要使用不同的构造函数。

更改此:

Html.Telerik().Grid(Model.AccessRequests) 

这样:

Html.Telerik().Grid<AccessRequests>() //Put in the appropriate type for AccessRequests 
+0

伟大的作品!谢谢! – morganpdx