Afficher un objet json complexe dans un datagrid ?
C'est encore moi,
J'ai maintenant un soucis avec dojox.grid.DataGrid.
Je voudrais le mapper avec une liste d'objets Json. Ces objets Json possède des sous-objets en propriété, et je voudrais afficher une de ces propriétés dans la grille.
Lorsque j'affiche une propriété "root", ça fonctionne. Mais lorsque je souhaite afficher une propritété d'un sous-objet, ça m'affiche "...". Je ne comprends pas. Y'a-t-il un moyen de remédier au problème ?
Voici un exemple d'un tableau Json :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| [
{
"id": 1,
"userInfo": {
"id": 1,
"group": {
"name": "my_group",
"id": 1
},
"fullName": "Admin ADMIN",
"isEnable": true,
"firstname": "Admin",
"lastname": "ADMIN"
},
"password": "my_pass",
"login": "admin",
}
] |
Voici ma structure :
Code:
1 2 3 4 5 6 7 8 9 10 11
| grid = new dojox.grid.DataGrid({
store: dataStore = dojo.data.ObjectStore({objectStore: accountsStore}),
structure: [
{name:"Id", field:"id", width: "50px"},
{name:"User", field:"userInfo.fullName", width: "200px"},
{name:"Email", field:"userInfo.email", width: "200px"},
{name:"Group", field:"userInfo.group.name", width: "200px"},
{name:"Status", field:"userInfo.isEnable", width: "200px"},
{name:"Login", field:"login", width:"200px"}
]
}, "accounts-table"); |
Le field 'id' s'affiche correctement, le field 'userInfo.fullName' affiche "..." à la place de la valeur.