PDA

View Full Version : Dataviews misconception



anarchos78
18 Apr 2012, 4:49 AM
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:

{"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}
]}
The proxy’s reader root is “member”.
What am I doing wrong?
Thank you in advance,
Tom

vietits
18 Apr 2012, 5:18 AM
With your data structure, you should config your reader root with "children[1].member"


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"
}
}

sskow200
18 Apr 2012, 5:34 AM
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')
});

});

sskow200
18 Apr 2012, 5:38 AM
Not sure if this link will work, but here is where I tested this....

http://jsfiddle.net/KWT7E/6/

anarchos78
18 Apr 2012, 8:50 AM
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