【发布时间】:2021-07-28 04:40:52
【问题描述】:
我有一个 JSON 格式的数据,需要在网格控件中显示。该 JSON 数据如果有一个数组,那么它会在网格中正确显示,并带有 (+) 号以展开,但如果它有一个具有其成员的对象,那么它只会显示为具有其类 ID 的列。
我的 JSON 字符串如下:
[
{
"customerID" : "AROUT",
"companyName" : "Around the Horn",
"contactName" : "Thomas Hardy",
"contactTitle" : "Sales Representative",
"address" : {
"street" : "120 Hanover Sq.",
"city" : "London",
"region" : "NULL",
"postalCode" : "WA1 1DP",
"country" : "UK",
"phone" : "(171) 555-7788"
}
},
{
"customerID" : "BERGS",
"companyName" : "Berglunds snabbköp",
"contactName" : "Christina Berglund",
"contactTitle" : "Order Administrator",
"address" : {
"street" : "Berguvsvägen 8",
"city" : "Luleå",
"region" : "NULL",
"postalCode" : "S-958 22",
"country" : "Sweden",
"phone" : "0921-12 34 65"
}
},
{
"customerID" : "BLAUS",
"companyName" : "Blauer See Delikatessen",
"contactName" : "Hanna Moos",
"contactTitle" : "Sales Representative",
"address" : {
"street" : "Forsterstr. 57",
"city" : "Mannheim",
"region" : "NULL",
"postalCode" : 68306,
"country" : "Germany",
"phone" : "0621-08460"
}
}
]
我已经在 Grid 中加载了字符串,如下所示:
string jsonString = File.ReadAllText(@"D:\Data.txt");
JsonDataSource jsonDataSource = new JsonDataSource();
jsonDataSource.JsonSource = new CustomJsonSource(jsonString);
jsonDataSource.Fill();
gridControl1.DataSource = jsonDataSource;
如果数据仅在单个对象中接收,如何将带有 (+) 号的地址显示为扩展?
【问题讨论】:
标签: c# devexpress xtragrid gridcontrol devexpress-windows-ui