我有 2 级层次的剑道网格。由于每次我无法获得选定的行 ID 并且无法在子网格的更改事件上应用工具提示时,子网格都有唯一的名称。
父网格名称=“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#") 不可访问。请让我知道如何获取子网格的数据项属性并在子网格上应用工具提示。