我们如何向kendo ui网格添加条件列。
我有像这样的JSON输入
[{
"ProductID": 1,
"ProductName": "Chai",
"Supplier": {
"SupplierID": 1,
"SupplierName": "Exotic Liquids"
},
"Category": {
"CategoryID": 1,
"CategoryName": "Beverages"
},
"UnitPrice": 18.0,
"UnitsInStock": 39,
"Discontinued": false,
"layers": [
{
"layer_Layer1": {
"layerType": "top",
"layer": "L1",
"groups": []
}
} ]
},{
"ProductID": 2,
"ProductName": "Chang",
"Supplier": {
"SupplierID": 1,
"SupplierName": "Exotic Liquids"
},
"Category": {
"CategoryID": 1,
"CategoryName": "Beverages"
},
"UnitPrice": 19.0,
"UnitsInStock": 17,
"Discontinued": false,
"layers": [
{
"layer_Layer2": {
"layerType": "top",
"layer": "L2",
"groups": []
}
}
]
}]
columns.fields
我在layers[0].layer_Layer1.layer
,但有时会得到layers[0].layer_Layer2.layer
。
我们如何在kendo ui中配置它?
Plunker:here
答案 0 :(得分:1)
如果我说得对,你想在列中显示layer_Layer1
或layer_Layer2
的值,具体取决于哪一个是空白。
您可以尝试使用template:
# if (layers && layers[0].layer_Layer1) { #
#: layers[0].layer_Layer1.layer #
# } else if (layers && layers[0].layer_Layer2) { #
#: layers[0].layer_Layer2.layer #
# } #