2

我有父網格和子網格,我使用kendo UI Grid(層次網格格式) 將子網格數據綁定到父網格中對應的行我能展現孩子網僅第一行,並不能表現出相同的細節再行...無法將子網格綁定到kendo中的第二行Hierarchy UI grid

這是我爲網格視圖...

@model IEnumerable<KendoSampleMVCApp.Models.EmployeesDetailsModel> 
@{ 
    ViewBag.Title = "Index"; 
} 
<h2>Index</h2> 
@using (Html.BeginForm()) 
{ 
    @(Html.Kendo().Grid<KendoSampleMVCApp.Models.EmployeesDetailsModel>() 
     .Name("ParentGrids") 
     .Columns(columns => 
     { 
      columns.Bound(e => e.EmployeeID).Width(100); 
      columns.Bound(e => e.EmployeeFirstName).Width(100); 
      columns.Bound(e => e.EmployeeSecondName).Width(100); 
      columns.Bound(e => e.EmployeeCity).Width(100);   

     })    
     .Sortable() 
     .Pageable() 
     .Scrollable() 
     .ClientDetailTemplateId("template") 
     .HtmlAttributes(new { style = "height:430px;" }) 
     .DataSource(dataSource => dataSource 
      .Ajax() 
      .PageSize(5) 
      .Read(read => read.Action("HierarchyBinding_Employees", "HierarchyGridDisplay"))    
     )    
) 
    <script id="template" type="text/kendo-tmpl"> 
    @(Html.Kendo().Grid<KendoSampleMVCApp.Models.ShipDescriptionModel>() 
      .Name("ChildGrids") 
      .Columns(columns => 
      { 
       columns.Bound(o => o.ShipAddress).Width(70); 
       columns.Bound(o => o.ShipCountry).Width(70); 
       columns.Bound(o => o.ShipName).Width(70); 
      }) 
      .DataSource(dataSource => dataSource 
       .Ajax() 
       .PageSize(6) 
       .Read(read => read.Action("HierarchyBinding_Orders", "HierarchyGridDisplay")) 
      ) 
      .Pageable() 
      .Sortable() 
      .ToClientTemplate() 
    ) 
    </script> 
<script> 
    function dataBound() { 
     this.expandRow(this.tbody.find("tr.k-master-row").first()); 
    } 
</script> 
} 

,這是我的模型

public class EmployeesDetailsModel 
{ 
    public string EmployeeID { get; set; } 
    public string EmployeeFirstName { get; set; } 
    public string EmployeeSecondName { get; set; } 
    public string EmployeeCity { get; set; }   
} 
public class ShipDescriptionModel 
{ 
    public string ShipCountry { get; set; } 
    public string ShipAddress { get; set; } 
    public string ShipName { get; set; }  
} 
public class EmployeeShipModel 
{ 
    public EmployeesDetailsModel employeesshipments { get; set; } 
    public ShipDescriptionModel shipinfo { get; set; } 
} 

,你會請提出任何想法和需要view做了展示孩子網格數據到另一個行,以及...非常感謝

請任何變化看下面連接

enter image description here

圖像

enter image description here

回答

0

我相信這是因爲你有一個靜態的網格ID。你應該嘗試給它一個動態的,所以可以創建不同的子網格。這就是爲什麼它只能在第一條記錄上工作,因爲網格的名稱沒有變化。 嘗試做這個:

@(Html.Kendo().Grid<KendoSampleMVCApp.Models.ShipDescriptionModel>() 
     .Name("ChildGrid_#=EmployeeID#") 

正在發生的事情是,從父電網僱員被推倒,並被用於電網的命名約定。這樣你可以擁有儘可能多的子網格,就像你喜歡的一樣。

相關問題