var childGrid = $(#ParentGird).closest(".k-grid").data("kendoGrid");
childGrid..dataSource.filter({});
答案 0 :(得分:0)
在下面的示例中,我需要对子项进行的操作是将对象列表传递给控制器以进行验证,因此我要遍历行,获取子网格,然后获取网格的子项,然后也遍历这些行,然后将它们添加到数组中。
这对我和我所需要的都很好,并且在许多地方都得到了使用。
如果您需要更多帮助,请修改问题,让我知道您需要什么
这是我的带有子网格的网格
@(Html.Kendo().Grid<OrderLineViewModel>()
.Name("DispatchedGrid")
.Columns(columns =>
{
columns.Bound(e => e.OrderLineID).Visible(false);
columns.Bound(e => e.OrderDispatchID).Visible(false);
columns.Bound(o => o.OrderLineDispatchID).Visible(false);
columns.Bound(e => e.OrderLineNo);
columns.Bound(e => e.ProductCode);
columns.Bound(e => e.ProductItemNumber);
columns.Bound(e => e.ProductDescription);
columns.Bound(e => e.Quantity);
}).NoRecords("Blank Dispatch - Back Order")
.AutoBind(false)
.ClientDetailTemplateId("template")
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(6)
.Read(read => read.Action("GetOrderLines", "Dispatch"))
)
.Events(events => events.DataBound("fe_dispatch.dataBoundDispatch"))
)
<script id="template" type="text/kendo-tmpl">
@(Html.Kendo().Grid<OrderLineDispatchViewModel>()
.Name("grid_#=OrderLineID#") // template expression, to be evaluated in the master context
.Columns(columns =>
{
columns.Bound(o => o.OrderID).Visible(false);
columns.Bound(o => o.OrderLineID).Visible(false);
columns.Bound(o => o.BoxQuantity).Visible(false);
columns.Bound(o => o.LotNumber).Width(200);
columns.Bound(o => o.InventoryQuantity);
columns.Bound(o => o.Bin).Width(200);
columns.Bound(o => o.DispatchedQuantity).Width(100); // If Qty = 0 then need to have a spinner here that will allow for bin selection.
})
.Editable(m => m.Mode(GridEditMode.InCell).DisplayDeleteConfirmation(false))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Read(read => read.Action("GetOrderDispatchLines", "Dispatch", new { orderLineId = "#=OrderLineID#", dispatchId = "#=OrderDispatchID#" }))
.Model(model =>
{
model.Id(l => l.OrderLineID);
model.Field(p => p.DispatchedQuantity).Editable(true);
model.Field(p => p.LotNumber).Editable(false);
model.Field(p => p.InventoryQuantity).Editable(false);
model.Field(p => p.Bin).Editable(false);
})
)
.ToClientTemplate())
然后在TypeScript中,这就是我的方法中的内容(针对您的需要进行了精简)
var parentGrid: kendo.ui.Grid = $("#DispatchGrid").data("kendoGrid") as any;
var gridDataRow = parentGrid.dataSource.data();
$.each(gridDataRow,
(index, pItem) => {
var childGrid: kendo.ui.Grid = $("#grid_" + pItem.OrderLineID).data("kendoGrid") as any;
$.each(childGrid.dataSource.data(),
(index, cItem) => {
if (cItem.DispatchQuantity < 0) {
console.log(cItem);
dispatchItems.push({
OrderID: pItem.OrderID,
PickId: pickId,
OrderLineID: pItem.OrderLineID,
OrderLineNo: pItem.OrderLineNo,
ProductCode: pItem.ProductCode,
BoxQuantity: pItem.BoxQuantity,
ProductItemNumber: pItem.ProductItemNumber,
Description: pItem.ProductDescription,
LotNumber: cItem.LotNumber,
InventoryQuantity: cItem.InventoryQuantity,
Bin: cItem.Bin,
Quantity: cItem.DispatchQuantity,
});
});
});