问题描述
我正在使用分离的主细节kendo ui网格.主网格位于选项卡1(tabstrip.select(0))中.添加/编辑(用于主网格)的字段位于首页的选项卡2(tabstrip.select(1))中.在Tabstrip 2中,我为详细信息网格嵌套了Tabstrip(位于底部的中间页面). 详细信息"网格位于嵌套的Tabstrip 1(tabstripNested.select(0))中,用于添加/编辑的字段位于嵌套的Tabstrip 2(tabstripNested.select(1))中.我想要的是?当我选择主网格中的某些行以在详细信息网格中显示适当的条目时,我希望这样做.这是我的masterDataSource:
I am working with master-details kendo ui grid, which is separated. Master grid is located within tabstrip 1 (tabstrip.select(0)). Fields for add/edit (for master grid) is located within tabstrip 2 (tabstrip.select(1)) in top page. In tabstrip 2 I have nested tabstrips for details grid (in middle-bottom page). Details grid is located within nested tabstrip 1 (tabstripNested.select(0)) and fields for add/edit is located within nested tabstrip 2 (tabstripNested.select(1)). What I want? I want that when I select some row in master grid that display appropriate entries in details grid. This is my masterDataSource:
var masterDataSource = new kendo.data.DataSource({
data: [
{ Id: 1, fieldMaster1: "10236", fieldMaster2: "20.01.2015", fieldMaster3: "24.01.2015", fieldMaster4: 1900.0, fieldMaster5: 1900.0, fieldMaster6: 0.0, fieldMaster7: "someth", fieldMaster8: "test" },
{ Id: 2, fieldMaster1: "10648", fieldMaster2: "26.01.2015", fieldMaster3: "28.01.2015", fieldMaster4: 7990.0, fieldMaster5: 7990.0, fieldMaster6: 0.0, fieldMaster7: "skafiskafnjak", fieldMaster8: "test 2" },
{ Id: 3, fieldMaster1: "10700", fieldMaster2: "22.01.2015", fieldMaster3: "25.01.2015", fieldMaster4: 2720.0, fieldMaster5: 2720.0, fieldMaster6: 0.0, fieldMaster7: "temp", fieldMaster8: "test 3" },
{ Id: 4, fieldMaster1: "10810", fieldMaster2: "24.01.2015", fieldMaster3: "27.01.2015", fieldMaster4: 0.0, fieldMaster5: 0.0, fieldMaster6: 0.0, fieldMaster7: "hlabuka", fieldMaster8: "test 4" },
{ Id: 5, fieldMaster1: "10101", fieldMaster2: "29.01.2015", fieldMaster3: "30.01.2015", fieldMaster4: 0.0, fieldMaster5: 0.0, fieldMaster6: 0.0, fieldMaster7: "descr", fieldMaster8: "test 5" },
{ Id: 6, fieldMaster1: "10364", fieldMaster2: "25.01.2015", fieldMaster3: "31.01.2015", fieldMaster4: 0.0, fieldMaster5: 0.0, fieldMaster6: 0.0, fieldMaster7: "TestNova", fieldMaster8: "" }
],
schema: {
model: {
id: "Id",
fields: {
Id: { type: "number" },
fieldMaster1: { type: "string" },
fieldMaster2: { type: "string" },
fieldMaster3: { type: "string" },
fieldMaster4: { type: "number" },
fieldMaster5: { type: "number" },
fieldMaster6: { type: "number" },
fieldMaster7: { type: "string" },
fieldMaster8: { type: "string" }
}
}
}
});
这是我的主网格:
var gridMaster = $("#gridMaster").kendoGrid({
columns: [
{ field: "Id", hidden: true },
{ field: "fieldMaster1", width: "50px" },
{ field: "fieldMaster2", width: "77px" },
{ field: "fieldMaster3", width: "70px" },
{ field: "fieldMaster4", hidden: true },
{ field: "fieldMaster5", width: "170px" },
{ field: "fieldMaster6", hidden: true },
{ field: "fieldMaster7", width: "80px" },
{ field: "fieldMaster8", width: "80px" }
],
dataSource: masterDataSource,
selectable: true,
filterable: true,
scrollable: true,
pageable: {
pageSize: 16
},
toolbar: [{
name: "create"
}]
});
这是我的detailsDataSource:
This is my detailsDataSource:
var detailsDataSource = new kendo.data.DataSource({
data: [
{ Id: 1, masterDataId: 1, fieldDetails1: "20.01.2015", fieldDetails2: "096680", fieldDetails3: "descr1", fieldDetails4: 1000.00, fieldDetails5: 1000.00, fieldDetails6: "ETF", fieldDetails7: "entry1", fieldDetails8: "tmp", fieldDetails9: "20.03.2016", fieldDetails10: "", fieldDetails11: 0.00 },
{ Id: 2, masterDataId: 1, fieldDetails1: "26.01.2015", fieldDetails2: "100258", fieldDetails3: "descr2", fieldDetails4: 900.00, fieldDetails5: 900.00, fieldDetails6: "TMP", fieldDetails7: "entry2", fieldDetails8: "tmp2", fieldDetails9: "20.03.2016", fieldDetails10: "", fieldDetails11: 0.00 },
{ Id: 3, masterDataId: 2, fieldDetails1: "22.01.2015", fieldDetails2: "122554", fieldDetails3: "descr3", fieldDetails4: 970.00, fieldDetails5: 970.00, fieldDetails6: "TMP", fieldDetails7: "entry3", fieldDetails8: "tmp", fieldDetails9: "20.03.2016", fieldDetails10: "", fieldDetails11: 0.00 },
{ Id: 4, masterDataId: 3, fieldDetails1: "24.01.2015", fieldDetails2: "200148", fieldDetails3: "descr4", fieldDetails4: 2000.00, fieldDetails5: 2000.00, fieldDetails6: "ETF", fieldDetails7: "entry1", fieldDetails8: "tmp2", fieldDetails9: "20.03.2016", fieldDetails10: "", fieldDetails11: 0.00 },
{ Id: 5, masterDataId: 2, fieldDetails1: "29.01.2015", fieldDetails2: "344688", fieldDetails3: "descr5", fieldDetails4: 1970.00, fieldDetails5: 1970.00, fieldDetails6: "TMP", fieldDetails7: "entry3", fieldDetails8: "tmp", fieldDetails9: "20.03.2016", fieldDetails10: "", fieldDetails11: 0.00 },
{ Id: 6, masterDataId: 2, fieldDetails1: "25.01.2015", fieldDetails2: "188366", fieldDetails3: "descr", fieldDetails4: 2250.00, fieldDetails5: 2250.00, fieldDetails6: "TMP", fieldDetails7: "entry2", fieldDetails8: "tmp", fieldDetails9: "20.03.2016", fieldDetails10: "", fieldDetails11: 0.00 },
{ Id: 7, masterDataId: 3, fieldDetails1: "24.01.2015", fieldDetails2: "264486", fieldDetails3: "descr1", fieldDetails4: 720.00, fieldDetails5: 720.00, fieldDetails6: "ETF", fieldDetails7: "entry2", fieldDetails8: "tmp", fieldDetails9: "20.03.2016", fieldDetails10: "", fieldDetails11: 0.00 },
{ Id: 8, masterDataId: 2, fieldDetails1: "30.01.2015", fieldDetails2: "400822", fieldDetails3: "descr", fieldDetails4: 2800.00, fieldDetails5: 2800.00, fieldDetails6: "ETF", fieldDetails7: "entry1", fieldDetails8: "tmp2", fieldDetails9: "20.03.2016", fieldDetails10: "", fieldDetails11: 0.00 }
],
schema: {
model: {
id: "Id",
fields: {
Id: { type: "number" },
masterDataId: { type: "number" },
fieldDetails1: { type: "string" },
fieldDetails2: { type: "string" },
fieldDetails3: { type: "string" },
fieldDetails4: { type: "number" },
fieldDetails5: { type: "number" },
fieldDetails6: { type: "string" },
fieldDetails7: { type: "string" },
fieldDetails8: { type: "string" },
fieldDetails9: { type: "string" },
fieldDetails10: { type: "string" },
fieldDetails11: { type: "number" }
}
}
}
});
这是我的详细信息表格:
This is my details grid:
var gridDetails = $("#gridDetails").kendoGrid({
columns: [
{ field: "Id", hidden: true },
{ field: "masterDataId", hidden: true },
{ field: "fieldDetails1", width: "70px" },
{ field: "fieldDetails2", width: "65px" },
{ field: "fieldDetails3", width: "170px" },
{ field: "fieldDetails4", width: "80px" },
{ field: "fieldDetails5", width: "80px" },
{ field: "fieldDetails6", width: "90px" },
{ field: "fieldDetails7", width: "120px" },
{ field: "fieldDetails8", hidden: true },
{ field: "fieldDetails9", hidden: true },
{ field: "fieldDetails10", hidden: true },
{ field: "fieldDetails11", hidden: true }
],
dataSource: detailsDataSource,
selectable: true,
filterable: true,
scrollable: true,
pageable: {
pageSize: 10
},
toolbar: [{
name: "create",
text: "Add New"
}],
height: 205
});
detailsDataSource具有masterDataId字段,该字段与masterDataSource中的ID相等.因此,当我在主网格中选择某行时,需要从明细网格中显示适当的记录.例如:当我选择主网格中的第一行时,我需要显示明细网格中的前两个记录(masterDataId = 1).如果选择主网格中的第二行,则需要显示明细网格中的第三,第五,第六和第八行(masterDataId = 2).实现此目的的最佳方法是什么?任何帮助表示赞赏.预先谢谢你.
detailsDataSource have masterDataId field, which is equal with Id from masterDataSource. Therefore, when I select some row in master grid, I need to display the appropriate records from details grid. For Example: when I select first row in master grid, I need to display first two records from details grid (masterDataId = 1). If I select second row in master grid I need to display third, fifth, sixth and eighth row from details grid (masterDataId = 2). What is the best way for implementing this? Any help appreciated. Thank you in advance.
推荐答案
我不确定我是否对您100%正确,但是我根据您的情况给出了一个简单的例子.关键是,当您 change
在主网格的选定行中,您必须过滤详细信息网格,例如:
I'm not sure if I get your 100% right, but I have made a simple example based on your case. The point is, when you change
the master grid's selected row, you have to filter the detail grid, like:
change: function() {
var gridDetails = $("#grid-detail").data("kendoGrid");
var dataItem = this.dataItem(this.select());
gridDetails.dataSource.filter({ field: "parentId", value: dataItem.id, operator: "eq" });
}
这篇关于主从-kendo ui网格(当在主网格中选择行时,在详细信息网格中获得条目)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!