PDA

View Full Version : data view getting data problem



rahulmehta
7 Aug 2010, 2:59 AM
i have two data view gibview nad userview in both json are coming right from store but gibview is showing correct but userview is not showing correct why pls help

var gibstore = new Ext.data.GroupingStore({
proxy: new Ext.data.HttpProxy({
url: 'yapi/get_gibowned.php?userid='+user.getData('userid'),
method: 'POST'
}),
reader: new Ext.data.JsonReader({
root:'gibs'
},
[
{name: 'gibid', type: 'numeric'},
{name: 'name', type: 'string'}
]),


});

var userstore = new Ext.data.GroupingStore({
proxy: new Ext.data.HttpProxy({
url: 'yapi/getuser.php?userid='+user.getData('userid'),
method: 'POST'
}),
reader: new Ext.data.JsonReader({
},
[
{name: 'alias', type: 'string'},
{name: 'firstname', type: 'string'},
{name: 'lastname', type: 'string'},
{name: 'userid', type: 'string'},
{name: 'email', type: 'string'}
]),


});


var userview = new Ext.DataView({
tpl: '<tpl for=".">' +
'<div class="vcard" style="">&nbsp;{firstname}{email}' +
'</div>' +
'</tpl>',
itemSelector: 'div.patient1-source',
overClass: 'patient-over1',
selectedClass: 'patient1-selected',
singleSelect: true,
store: userstore
});


// here i have shown the images in the data view in the tpl tag
var gibview = new Ext.DataView({
id:'a',
tpl: '<tpl for="."><form name="orderform">' +
'<div id="32" class="vcard" style="">&nbsp;{name}' +
'</div>' +
'</tpl>',
itemSelector: 'div.patient-source',
overClass: 'patient-over',
selectedClass: 'patient-selected',
singleSelect: true,
store: gibstore
});


if(!gibshowwindow)
{

var gibshowwindow = new Ext.Window({
minimizable: true,
title: 'View Gibs',
width: 300,
height: 300,
items:userview
});

}
gibstore.reload();
userstore.reload();
gibshowwindow.show();

Condor
7 Aug 2010, 3:38 AM
1. You didn't post your data, so I don't know if your stores are configured correctly. To be sure, add an exception listener to both stores.
2. Both your itemSelectors don't match any element inside the template.
3. Your gibview template generates invalid HTML (unclosed form tag).
4. I would add layout:'fit' to your window and autoScroll:true to the dataviews.

rahulmehta
7 Aug 2010, 3:47 AM
{ 'success': 'true', 'alias' :'rahul' , 'email':'rahul', 'firstname' :'rahul' , 'lastname' :'-' , 'userid':'1','gibid':'1' }
this is the reply of getuser.php userstore

{'success': 'true','message':'gibs owned','gibs':[{"gibid":"1","name":"rahuls Gib","uname":"rahul -"},{"gibid":"16","name":"Jane3's Gib","uname":"rahul -"}]}

and my gib view is woking giving me output but userview is not working




this is the json of gibstore

thanks condor for your concern..

please help in this ...

Condor
7 Aug 2010, 3:53 AM
A JsonReader expects an array for the data and you are returning a single object.

You can fix this by writing a root function that returns the object as an array, e.g.

reader: new Ext.data.JsonReader({
root: function(v){
return [v];
},
fields: [
{name: 'alias', type: 'string'},
{name: 'firstname', type: 'string'},
{name: 'lastname', type: 'string'},
{name: 'userid', type: 'string'},
{name: 'email', type: 'string'}
]
}),

rahulmehta
7 Aug 2010, 4:08 AM
great it worked thank you so much ..