我对KenfoUI网格有问题。从服务器端我发送JSON数据:
{
"data": [{
"process": {
"id": "myProcess2:1:1206",
"description": null,
"name": "My process 2",
"version": 1
},
"id": 42066,
"description": "unisono-rest-evenem",
"type": {
"id": 2,
"translation": "Faktura sprzedażowa",
"name": "salesInvoice"
},
"triger": {
"id": 42048,
"name": "Document recognized trigger",
"code": "ocrEndTrigger",
"type": "DOCUMENT_RECOGNIZED"
}
}, {
"process": {
"id": "myProcess2:1:1206",
"description": null,
"name": "My process 2",
"version": 1
},
"id": 42067,
"description": "6756757",
"type": {
"id": 5,
"translation": "Słownik stawek VAT",
"name": "dictVatRates"
},
"triger": {
"id": 42048,
"name": "Document recognized trigger",
"code": "ocrEndTrigger",
"type": "DOCUMENT_RECOGNIZED"
}
}, {
"process": {
"id": "myProcess2:1:1206",
"description": null,
"name": "My process 2",
"version": 1
},
"id": 42068,
"description": "56546546",
"type": {
"id": 1,
"translation": "Faktura",
"name": "invoice"
},
"triger": {
"id": 42047,
"name": "New document trigger",
"code": "createDocument",
"type": "CREATE_DOCUMENT"
}
}, {
"process": {
"id": "myProcess2:1:1206",
"description": null,
"name": "My process 2",
"version": 1
},
"id": 42069,
"description": "swswsws",
"type": {
"id": 5,
"translation": "Słownik stawek VAT",
"name": "dictVatRates"
},
"triger": {
"id": 42047,
"name": "New document trigger",
"code": "createDocument",
"type": "CREATE_DOCUMENT"
}
}],
"total": 4
}
我在gird中定义了列:
columns: [{
field: "process",
title: "Nazwa procesu",
editor: staticEditors.processEditor,
"template": function (data) {
if (data.process != null && data.process != undefined) {
return "<span class='gridText' title='" + data.process.name + "'>" + data.process.name + "</span>"
} else {
return "<span></span>"
}
}
}, {
field: "type",
title: "Typ dokumentu",
editor: $scope.typeEditor,
"template": function (data) {
if (data.type != null && data.type != undefined) {
return "<span class='gridText' title='" + data.type.translation + "'>" + data.type.translation + "</span>"
} else {
return "<span></span>"
}
}
}, {
field: "triger",
title: "Wyzwalacz",
editor: staticEditors.triggerEditor,
"template": function (data) {
if (data.triger != null && data.triger != undefined) {
return "<span class='gridText' title='" + data.triger.name + "'>" + data.triger.name + "</span>"
} else {
return "<span></span>"
}
}
}, {
field: "description",
title: "Description",
"template": function (data) {
if (data.description != null && data.description != undefined) {
return "<span class='gridText' title='" + data.description + "'>" + data.description + "</span>"
} else {
return "<span></span>"
}
}
}
模板功能存在问题,因为数据对象没有所有数据。我注意到嵌套数据有问题(字段类型,触发器,进程有null或字符串(&#34; [object Object]&#34;)值。)
我该如何解决这个问题?
答案 0 :(得分:0)
我发现了问题。 我将schema.model.field定义为数字(字符串)。当我删除它,一切正常。
答案 1 :(得分:-1)
模板不是列中的字符串,
尝试这样,
{
field: "triger",
title: "Wyzwalacz",
editor: staticEditors.triggerEditor,
template: function (data) {
if (data.triger != null && data.triger != undefined) {
return "<span class='gridText' title='" + data.triger.name + "'>" + data.triger.name + "</span>"
} else {
return "<span></span>"
}
}
删除"template"
并执行此操作template
我认为这解决了您的问题。