PDA

View Full Version : no data in panel



kjcr
16 Oct 2012, 9:37 PM
hello
i'm new to Extjs

i have a problem.
please help me.



my json

{"root":
"success":"false"
"items":[
{
"type":"Error",
"title":"Title",
"message":"Message",
"key":""
},
{
"type":"Error",
"title":"Title",
"message":"Message",
"key":""
}
]}


my store

var project_val = Ext.create('Ext.data.ArrayStore', {
model: 'project_val',
autoLoad : true
});

my model

Ext.define('project_val',{
extend:'Ext.data.Model',
fields:[
{name:'success',type:'string'},
{name:'type',type:'string',mapping:'items.type'},
{name:'title',type:'string',mapping:'items.title'},
{name:'message',type:'string',mapping:'items.message'},
{name:'key',type:'string',mapping:'items.key'}
],
hasOne: {model:'items',name:'items'},
proxy:{
type: 'ajax',
url:'resource/json/result.json',
reader:{
type:'json',
root:'root'
}
}
});

Ext.define('items',{
extend:'Ext.data.Model',
fields:[
{name:'type',mapping:'record[0].type'},
{name:'title',mapping:'record[1].title'},
{name:'message',mapping:'record[2].message'},
{name:'key',mapping:'record[3].key'}
],
belongTo:'project_val'
});


and my view , panel

//xtemplate
var temp = new Ext.Template(
'<div>hello</div>'
&nbsp;);

// panel

var valPanel = Ext.create('Ext.panel.Panel',{
store:project_val,
title:'Your dataset show below error',
id:'gridVal',
tpl:temp
});



i can see my panel and title
but i can't see my data.
please help me.

sword-it
17 Oct 2012, 2:21 AM
Please put your sample code always under code tag.
Your json is not valid, the valid json is -


{
"root": {
"success": "false",
"items": [
{
"type": "Error",
"title": "Title",
"message": "Message",
"key": ""
},
{
"type": "Error",
"title": "Title",
"message": "Message",
"key": ""
}
]
}
}