Asp.net mvc MVC剑道UI网格-动态列对象
您好,我正在构建一个网格,该网格根据特定对象的数量具有动态列。。这里有一个例子Asp.net mvc MVC剑道UI网格-动态列对象,asp.net-mvc,kendo-ui,telerik,telerik-grid,Asp.net Mvc,Kendo Ui,Telerik,Telerik Grid,您好,我正在构建一个网格,该网格根据特定对象的数量具有动态列。。这里有一个例子 public class Team { string name {get;set;} List<members> memberslist {get;set;} } public class member{ string name {get;set;} int goals {get;set;} } 我想要
public class Team
{
string name {get;set;}
List<members> memberslist {get;set;}
}
public class member{
string name {get;set;}
int goals {get;set;}
}
我想要的结果是这样的:
队名,约翰·史密斯·泰勒·费尔南德斯
AJAX 22 1. 3.
米兰 0 1. 二,
有什么想法吗?!如何完成将打印对象[object],我尝试了很多stufs,但没有成功。。谢谢,最简单的方法是通过JSON。将列列表转换为json并将其传递给列,请参见下文。在最底部你可以看到我把柱子推到网格上。下面您可以看到JSON本身的样子
var gridJSON = {
dataSource: {
data: data,
schema: {
model: {} // the model gets filled in by the JSON coming from the database
},
pageSize: 20
},
height: 550,
groupable: false,
sortable: true,
resizable: true,
filterable: {
extra: false,
operators: {
string: {
startswith: "Starts with",
eq: "Is equal to",
neq: "Is not equal to"
}
}
},
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
toolbar: kendo.template($("#template").html())
};
gridJSON.columns = currentReport.JSON.columns;
gridJSON.dataSource.schema.model.fields = currentReport.JSON.fields;
以下是“currentReport.JSON.columns”的JSON
"columns" : [{
"field" : "ReceiverID",
"title" : "Receiver ID"
}, {
"field" : "ReceiverBatchID",
"title" : "Batch ID"
}, {
"field" : "PoNumber",
"title" : "PO Number"
}, {
"field" : "ReceiverTransactionDate",
"title" : "Receiver Trans Date",
"format" : "{0: yyyy-MM-dd}"
}, {
"field" : "PrintingLocation",
"title" : "Location"
}, {
"field" : "VendorID",
"title" : "Vendor ID"
}, {
"field" : "InNemo",
"title" : "InNemo"
}, {
"field" : "Path",
"title" : "Path",
"encoded" : "true",
"template": "#=Path#",
"width" : "50"
}
]
"columns" : [{
"field" : "ReceiverID",
"title" : "Receiver ID"
}, {
"field" : "ReceiverBatchID",
"title" : "Batch ID"
}, {
"field" : "PoNumber",
"title" : "PO Number"
}, {
"field" : "ReceiverTransactionDate",
"title" : "Receiver Trans Date",
"format" : "{0: yyyy-MM-dd}"
}, {
"field" : "PrintingLocation",
"title" : "Location"
}, {
"field" : "VendorID",
"title" : "Vendor ID"
}, {
"field" : "InNemo",
"title" : "InNemo"
}, {
"field" : "Path",
"title" : "Path",
"encoded" : "true",
"template": "#=Path#",
"width" : "50"
}
]