-
18 Apr 2012 4:49 AM #1
Answered: Dataviews misconception
Answered: Dataviews misconception
Hello to everyone,
I have a problem loading data in dataview. When I am trying to load data in panel using a template and static data everything is fine follow the link in jsfiddle.net: http://jsfiddle.net/anarchos78/dbCxS/5/
Now, I am trying to do the same by using model, store, template and dataview. Nothing happens (no data loaded). Notice that I want to do the same using a proxy. I had already tried it but nothing was loaded. Follow: http://jsfiddle.net/anarchos78/KWT7E/4/
In the second attempt you can see in the jsfiddle link that I had commented out a store with a proxy. The server’s JSON output is:
The proxy’s reader root is “member”.Code:{"children":[null,{"member":[{ "cls":"file", "text":"Gida Katsikis", "id":2001, "leaf":true, "biog":"The domestic goat (Capra aegagrus hircus) is a subspecies of goat domesticated from the wild goat of southwest Asia and Eastern Europe.}],"DATASET":1} ]}
What am I doing wrong?
Thank you in advance,
Tom
-
Best Answer Posted by vietits
With your data structure, you should config your reader root with "children[1].member"
Code:proxy: { type: 'ajax', url: 'http://localhost:8500/MVC/Book_Ledger/app/cf_scripts/Members.cfc?method=getAllMembers&id=1', reader: { type: 'json', root: "children[1].member" } }
-
18 Apr 2012 5:18 AM #2
With your data structure, you should config your reader root with "children[1].member"
Code:proxy: { type: 'ajax', url: 'http://localhost:8500/MVC/Book_Ledger/app/cf_scripts/Members.cfc?method=getAllMembers&id=1', reader: { type: 'json', root: "children[1].member" } }
-
18 Apr 2012 5:34 AM #3
You must tell the template where to start
You must tell the template where to start
Code:Ext.onReady(function() { Ext.define('MyModel', { extend: 'Ext.data.Model', fields: [ {name: 'name', type: 'string'}, {name: 'biog', type: 'string'} ], proxy: { type: 'memory', reader: { type: 'json' } } }); // Store with inline data Ext.define('MyStore', { extend: 'Ext.data.Store', model: 'MyModel', autoLoad: true, data: [{ name: 'Paparas', biog: 'Sigoura einai enas paparakos'}] }); Ext.define('MyView', { extend: 'Ext.view.View', store: Ext.create('MyStore'), autoShow: true, tpl: [ '<tpl for=".">', '<span class="selector">', '<b>Name: </b>', '{name}', '<br/>', '{biog}', '</span>', '</tpl>' ], itemSelector: 'span.selector', emptyText: 'No description available', prepareData: function(data) { return data; } }); var thePanel = new Ext.Panel({ height: 500, renderTo: Ext.getBody(), title: 'My Panel', items: Ext.create('MyView') }); });
-
18 Apr 2012 5:38 AM #4
-
18 Apr 2012 8:50 AM #5
Thank both of you (vietits and sskow). I marked vietits answer a best because this forum engine doesn't give the possibility to mark more that one answer as best, so i have chosen the first on the row. Thank you again.
Tom


Reply With Quote