我有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屬性並在子網格上應用工具提示。