Hello Guys,
I want to have a dynamic view layout that should be defined in the same store as the data is. I first tryed the sample below with the view layout defined in the js-file. This works fine.
var store;
var ddata;
var grid;
var view1 = {
cells: [[
{name: 'name', field: "name"},
{name: 'vorname', width: "25em", field: "vorname"}
],
[
{name: 'anschrift', colSpan:"2", field: "anschrift"}
]
]
};
// a grid layout is an array of views.
var layout = [ view1 ];
function fktInit(){
store = new dojo.data.ItemFileReadStore({jsId: 'jsonStore', url: "grid_5a.json"});
ddata = new dojox.grid.data.DojoData(null, store, {jsId: 'model', clientSort: true, rowsPerPage: 5, query: {type:'record'}});
grid = new dojox.Grid({id: "grid", structure: layout, model: ddata});
dojo.byId("content").appendChild(grid.domNode);
grid.setStructure(layout);
grid.startup();
}
Then I tryed to put the view layout in a jason file store (viewlayout.json):
[{"cells": [[
{"field": "name", "name": "name"},
{"field": "vorname", "name": "vorname", "width": "25em"}
],
[
{"field": "anschrift", "name": "anschrift", "colSpan":"2"}
]
]
}]
and changed the code below:
function fktInit(){
store = new dojo.data.ItemFileReadStore({jsId: 'jsonStore', url: "grid_6.json"});
request = store.fetch({query: {type:"cells"}, onComplete: fktCreateViewLayout});
ddata = new dojox.grid.data.DojoData(null, store, {jsId: 'model', clientSort: true, rowsPerPage: 5, query: {type:'record'}});
grid = new dojox.Grid({id: "grid", model: ddata});
dojo.byId("content").appendChild(grid.domNode);
dojo.xhrGet({
url:"viewlayout.json",
handleAs:"json",
load: function(o, ioArgs){
console.debug(o);
dijit.byId("grid").setStructure(o);
return o;
}
});
grid.startup();
}
this works fine too, but now i put the view layout in the SAME jason store and her is the problem. How can i get the view layout from this hierarchy?
this is the json file:
{ identifier: 'id', label: 'label',
items: [
{type:'record', id: 'Keiner', label:'Max Keiner', name:'Keiner', vorname:'Max', anschrift:'unbekannt verzogen', telefon:'', fax:'' },
{type:'record', id: 'Mann', label:'Harry Mann', name:'Mann', vorname:'Harry', anschrift:'unbekannt verzogen', telefon:'', fax:'' },
{type:'record', id: 'Altmann', label:'Alf Altmann', name:'Altmann', vorname:'Alf', anschrift:'unbekannt verzogen', telefon:'', fax:'' },
{type:'record', id: 'Neumann', label:'Udo Neumann', name:'Neumann', vorname:'Udo', anschrift:'unbekannt verzogen', telefon:'', fax:'' },
{type:'cells', id: 'cells', label:'cells', cells:[[
{"field": "name", "name": "name"},
{"field": "vorname", "name": "vorname", "width": "25em"}
],
[
{"field": "anschrift", "name": "anschrift", "colSpan":"2"}
]
]
}]
}
