我有这样的要求,比如我需要找到父网格行复选框,如果选中了父网格行复选框,那么我需要将所有子网格复选框设置为该父网格行复选框的 true,为此我已经这样做了...... .
<script type="text/javascript">
$(document).ready(function () {
$('#btnMove').click(function () {
var parentgrid = $('#GridParent').data('kendoGrid');
var childGrid = $('#GridParent').closest(".k-grid").data("kendoGrid");
var Count = $('#Gridparent').data("kendoGrid").dataSource.total();
alert(Count);
for (i = 0; i < Count; i++)
{
var isChecked = parentgrid.tbody.find('tr:eq(' + i + ')').find('td').find('.chkbxq').is(':checked');
alert(isChecked); // here i need to get the property of parent grid row checkbox and I am not getting this alert....
if (isChecked == true)
{
var allchildgridchkboxes = childGrid.tbody.find('td').find('chkbx');
alert(allchildgridchkboxes); // i am not getting this alert
// here i need to set the all checkboxes checked property to true
}
}
});
});
</script>
这是我在网格中定义复选框的视图...
看法
@using (Html.BeginForm())
{
@(Html.Kendo().Grid<Topco.TopMapp.MVC.Models.CostPageSearch>()
.Name("Gridparent")
.Columns(columns =>
{
columns.Template(@<text></text>).ClientTemplate("<input id='checkbox' onclick='grdChkBoxClick(this);' class='chkbxq' type='checkbox' />").Width(30);
columns.Bound(e => e.CostPage).Width(100);
columns.Bound(e => e.Description).Width(100);
columns.Bound(e => e.VendorName).Width(100);
columns.Bound(e => e.BillTypeDirect).Width(100);
columns.Bound(e => e.BillTypeWarehouse).Width(100);
columns.Bound(e => e.VendorName).Width(100);
})
.ClientDetailTemplateId("client-template")
.HtmlAttributes(new { style = "height:480px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(6)
.Read(read => read.Action("HierarchyBinding_Employees", "CostPageDisplay"))
)
.Events(events => events.DataBound("dataBound"))
)
<script id="client-template" type="text/kendo-tmpl">
@(Html.Kendo().Grid<Topco.TopMapp.MVC.Models.ItemsDescriptionModel>()
.Name("grid_#=CostPage#")
.Columns(columns =>
{
columns.Template(@<text></text>).ClientTemplate("<input id='checkbox' onclick='grdChkBoxClick(this); 'class='chkbxq' type='checkbox'/>").Width(30);
columns.Bound(o => o.ItemId).Width(100);
columns.Bound(o => o.ItemDescription).Width(100);
columns.Bound(o => o.BrandCode).Width(100);
columns.Bound(o => o.PackSize).Width(100);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Read(read => read.Action("HierarchyBinding_Orders", "CostPageDisplay" , new { employeeID = "#=CostPage#" }))
)
.ToClientTemplate()
)
</script>
<script>
function dataBound() {
this.expandRow(this.tbody.find("tr.k-master-row").first());
//alert('1');
}
</script>
任何人都可以帮助解决这个问题...如何找到选中的父网格行复选框以及如何获取子网格的所有复选框...。
请看图片...我需要获取两个网格的复选框参考
更新 :
<script type="text/javascript">
$(document).ready(function () {
$('#btnMove').click(function () {
debugger;
alert("button clicked");
var parentgrid = $('#GridParent').data('kendoGrid');
var count = $('#Gridparent').data('kendoGrid').dataSource.total();
alert(count);
var ischeckedone = parentgrid.tbody.find('td').find('.chkbxq').is(':checked');
alert(ischeckedone);
var rows = parentgrid.table.find('>tbody>tr').find('tr.k-state-selected').dataSource.total();
alert(rows);
//var sel = rows[0].cells[1].innerHTML;
//alert(sel);
//var gridchild = parentgrid.parents("[data-role=grid]").data("kendoGrid");
//var COUNT = parentgrid.parents("[data-role=grid]").data("kendoGrid").dataSource.total();
//var childGrid = $('#GridParent').closest(".k-grid").data("kendoGrid");
//var childgrid = parentgrid.detailCell.find('>.k-grid').data().kendoGrid;
//var anothercount = $('#GridParent').closest(".k-grid").data("kendoGrid").dataSource.total();
//alert(anothercount);
// var childrows = parentgrid.detailCell.find('>.k-grid').data().kendoGrid.dataSource.total();
// alert(childrows);
var chekbox = parentgrid.table.find('tr').find('td:first input').find('.chkbxq').is(':checked');
alert(chekbox);
for (i = 0; i < Count; i++) {
// var isChecked = parentgrid.tbody.find('tr:eq(' + i + ')').find('td').find('.chkbxq').is(':checked');
var chekbox = parentgrid.table.find('tr').find('td:first input').find('.chkbxq').is(':checked');
alert(chekbox);// din't worked
alert(isChecked);// din't worked
if (isChecked == true)
{
var allchildgridchkboxes = childGrid.tbody.find('td').find('chkbx');
alert(allchildgridchkboxes); // din't worked
}
}
});
});
</script>