2014-09-01 71 views
0

我有2個層次結構劍道網格。由於每次我無法獲取選定行ID並且無法應用子網格更改事件上的工具提示時,子網格具有唯一名稱。在層次結構kendo網格中的子網格上應用工具提示

父網格名稱= 「AccountStatusgrid」

  <script type="text/kendo" id="LocationsTemplate"> 
       @(Html.Kendo().Grid<NOC.Entities.Location>() 
        .Name("AccountStatusgrid_#=AccountId#") 
        .Columns(column => 
        { 
         column.Bound(c => c.LocationName).Title("Location Name").HeaderHtmlAttributes("style=align:center;").Width(100); 

         column.Template(@<text> </text>).ClientTemplate("<html><span>Device</span></html>").HeaderHtmlAttributes("style=align:center;").Title("Devices").Width(100); 

         for (int i = 0; i < Model.MockServiceHeaders.Count(); i++) 
         { 
          column.Bound(c => c.LocationStatus).Title(Model.MockServiceHeaders.ToList()[i].ServiceName.ToString()).Width(20).HtmlAttributes(new { title = " " }); 

         } 
        }) 
           .Selectable(selectable => selectable 

            .Mode(GridSelectionMode.Single) 

            .Type(GridSelectionType.Cell)) 
            .AutoBind(true) 
             .DataSource(source => source.Ajax() 
              .Model(model => 
              { 
               model.Id(o => o.LocationId); 

              }) 
              .ServerOperation(true) 
              .Events(events => events.Error("error_handler")) 
              .Read(read => read.Action("GetLocationData", "Account", new { AccountId = "#=AccountId#" })) 
             ) 
             .Events(events => events.DataBound("Grid_onRowDataBound").Change("Grid_onCellChange_Locations")) 
             .ClientDetailTemplateId("DeviceTemplate") 
             .ToClientTemplate() 

           ) 

      </script> 

      function Grid_onCellChange_Locations() { 

        var grid = $("AccountStatusgrid_#=AccountId#").data("kendoGrid"); 

        var dataItem = grid.dataItem(grid.select().closest("tr")); 

        var Sel_accountId = dataItem.AccountId; 
        var Sel_loactionId = dataItem.LocationId; 
        var Sel_deviceId = dataItem.DeviceId; 

        var selected = $.map(this.select(), function (item) { 

         var index = $(item).index(); 
         if (grid.columns[index - grid.dataSource._group.length] != undefined) { 

          ServiceName = grid.columns[index - grid.dataSource._group.length].title; 

         } 
         else 
          ServiceName = ""; 

         Selectedservicestatus = $(item).text() 
        }); 

        $("AccountStatusgrid_#=AccountId#").kendoTooltip({ 
         filter: 'td[title]', 
         showOn: "click", 
         content: { 
          url: '@Url.Action("Tooltip", "Account")', 
          data: { accountId: Sel_accountId, locationId: Sel_loactionId, deviceId: Sel_deviceId, serviceName: ServiceName } 
         }, 
         width: 290, 
         height: 360, 
         position: "right" 

        }); 

       } 

目前$( 「AccountStatusgrid _#= ACCOUNTID#」)是不可訪問。 請讓我知道如何獲得子網格的dataitem屬性並在子網格上應用工具提示。

回答

0

你可以試試下面的代碼獲取孩子電網的DataItem ..

$("#grid").delegate(".details-button", "click", function(e) { 
var row = $(this).closest("tr"), 
    grid = $(this).parents("[data-role=grid]").data("kendoGrid"); //gets child grid 

var model = grid.dataItem(row); 
console.log(model); //model contains the id 

}

或使用該代碼可能會幫助你。

function expand(e) { 
var dataItem = this.dataItem(e.node); 
if (dataItem.hasChildren) { 
    var childItems = dataItem.children.data(); 
}   

,如果你喜歡我的答案,那麼請不要忘記投票我..

0

您可以將一個類來要與一列屬性的工具提示你的孩子網格的單元:

mySubGrid.element.kendoTooltip({ 
filter: ".tooltip2", 
position: "right", 
content: "My tooltip."}).data("kendoTooltip"); 
{ field: "MyColumn", title: "Ref #", attributes: { "class": "tooltip2" } }, 

然後用在類名的過濾器定義提示

相關問題