本文介绍了如何将dataSource分配给DetailgridOptions(dataItem)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个剑道网格,每行都有一个按钮,单击按钮会打开一个弹出窗口,每次单击按钮时会弹出一个不同的网格,并且在弹出网格的每一行中都有一个明细团队板,其中包含另一个网格
I have a kendo grid which has buttons in every row, On click the buttons open a pop-up with different grid on each button click, and there is a detail teamplate in each row of pop-up grid which contains another grid.
现在的问题是,在调用detailGridOptions(dataItem)函数时如何将dataSource分配给第三网格.
var p=0;
$scope.detailGridOptions = function (dataItem) {
return {
dataSource: new kendo.data.DataSource({
schema: {
model: {
id: 'Id',
fields: {
Id: { type: 'number' },
PId: { type: 'number' },
ParentId: { type: 'number' },
SLength: { type: 'number' },
SVolume: { type: 'number' },
Status: { type: "String" }
}
}
}
}),
//new kendo.data.dataSource({
//read: function (options) {
// options.success($scope.splGridData);
//},
filter: [
{ field: "ParentId", operator: "neq", value: p },
{ field: "ParentId", operator: "eq", value: dataItem.Id }
],
}),
columns: [
{
field: "SLength",
width: "55px"
},
{
field: "SVolume",
width: "55px"
}
]
};
}
ciSetUp.GetCurveDetailsData(Id).then(function () {
//debugger;
if (ciSetUp.getcurvedata.ReturnedResult.length > 0) {
$scope.CgridDataSource.data(ciSetUp.getcurvedata.ReturnedResult);
ciSetUp.GetCurveDetailsData(Id).then(function () {
$scope.detailGridOptions.data(ciSetUp.getcurvedata.ReturnedResult);
});
}
});
<div id="details-container" kendo-window="modal" k-title="'Pump Details'" k-visible="false" k-modal="true"> <!--style="height:370px;width:600px;"-->
<dl>
<dt id="pn"> Name : </dt>
<dt id="pk"> {{P}} </dt>
<dt id="sn">Status : </dt>
<dt id="sk"> {{Status}} </dt>
</dl>
<div class="tabcontainer">
<div class="cphPadd">
<div class="rowdiv">
<kendo-grid options="CgridOptions" k-data-source="CgridDataSource" style="margin-bottom:10px">
<div k-detail-template>
<div kendo-grid k-options="detailGridOptions(dataItem)"></div>
</div>
</kendo-grid>
</div>
</div>
<button id="b3" class="button" ng-click="modal.close()">Cancel</button>
<button id="b2" class="button">Save</button>
<button id="b1" class="button" ng-click="modal.reload()">Refresh </button>
</div>
</div>
</div>
我将从ciSetUp获取数据.
I'll be getting data from ciSetUp.
推荐答案
$scope.detailGriddataSource = new kendo.data.DataSource({
filter: [
{ field: "ParentId", operator: "neq", value: p },
],
schema: {
model: {
id: 'Id',
fields: {
Id: { type: 'number' },
PId: { type: 'number' },
ParentId: { type: 'number' },
SLength: { type: 'number' },
SVolume: { type: 'number' },
Status: { type: "String" }
}
}
}
}),
$scope.detailGridOptions = function (dataItem) {
var newData = $scope.detailGriddataSource.data().filter(function (el) {
return el.ParentId == dataItem.Id && el.ParentId != 0;
});
if (newData.length > 0) {
var Childdata = new kendo.data.DataSource({
data: newData,
});
return {
dataSource: Childdata,
columns: [
{
field: "SLength",
width: "55px"
},
{
field: "SVolume",
width: "55px"
}
]
};
}
}
这篇关于如何将dataSource分配给DetailgridOptions(dataItem)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!