0

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 ?

enter image description here

4

1 回答 1

2

您看到的原因[object Object]是因为address它是 object 类型,并且您将它传递到您的单元格中,这会将其转换为string。因此,单元格中填充了对象的字符串表示形式,在这种情况下为[object Object].


示例 1:

function formatAddress(address){
    return address.street + ' ' + address.phone;
}

var grid = $("#grid").kendoGrid({
    dataSource: {
        pageSize: 20,
        data: createRandomData(50)
    },
    pageable: true,
    height: 430,
    columns: [
        { field: "FirstName", title: "First Name", width: "140px" },
        { field: "LastName", title: "Last Name", width: "140px" },
        // `formatAddress` will be called from the global variable scope like eval() usually does
        { field: "Address", template: "#= formatAddress(data) #" } 
    ]
}).data("kendoGrid");


示例 2:(MVVM)

<div id="grid" data-role="grid" data-bind="source: gridSource"
     data-columns='[{field:"FirstName",title:"First Name"}, {field:"LastName",title:"Last Name"}, {field:"Address",template:"#= formatAddress(data) #"}]'>
</div>
于 2013-10-24T11:53:50.953 回答