Kendo UI Grid具有动态列和将JSON对象显示为[object Object]的随机数据 [英] Kendo UI Grid with dynamic columns and random data showing JSON objects as [object Object]
问题描述
数据是随机的,我无法预测这些列.我从远程读取数据并将其显示在网格上.
The data is random and I cant predict the columns. I read data from remote and display it on the grid.
我在Kendo UI网格中以[object Object]
的形式获取json对象,如何可视化它,或者有什么方法可以显示Kendo网格中单元格的详细视图?
I get json objects as [object Object]
in Kendo UI Grid, How can i visualize it or is there any way to show a detail view of a cell in a Kendo grid ?
如果在这些单元格中插入JSON
对象的treeview
,我认为这将解决问题.
I think it would solve the issue if I can insert a treeview
of JSON
Object in those cells.
推荐答案
问题是您的Address是一个复杂的对象,因此您需要告诉kendoGrid如何显示它.例如,我有一个复杂的对象Connected,如下所示: {Connected:{Value:3,Percentage:100}}
The problem is that your Address is a complex object, so you need to tell kendoGrid how to display it. For example, I have a complex object Connected, as follows: {Connected:{Value:3, Percentage:100}}
如果仅将其映射到某些列,则将在网格中显示[object Object],与您的体验相同.
If I simply map it to some column, I will get [object Object] displaying in my grid, identical to your experience.
解决方案:
比方说,我需要如下所示显示我的Connected对象:'3(100%)'.网格无法知道这一点.因此,我必须在列声明中创建一个模板:
Let's say that I need to display my Connected object as follows: '3 (100 %)'. The grid has no way to know that. Therefore I had to create a template in my column declarations:
var gridColumns = [
{ field: "Connected", title: "Connected", template: function(data) {
return data["Connected"].Value + " (" + data["Connected"].Percentage + " %)";
}
}
];
这就是我得到的:
这篇关于Kendo UI Grid具有动态列和将JSON对象显示为[object Object]的随机数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!