PDA

View Full Version : listview datastore loaddata problem



jacquesh
19 Jan 2011, 1:39 AM
Hello,

How can I refresh a listview's content when using data property.
When I use URL, when I fire reload event (via getStore()) content is reloaded, with data I use loaddata content are not updated ?


dsjson_drawers = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
dsjson_drawers.superclass.constructor.call(this, Ext.apply({
storeId: 'dsjson_drawers',
data:{"resultat": [[0, "Select a safe"]]},
autoLoad: true,
root: 'resultat',
fields: [
{
name: 'drawerid',
mapping:0
},{
name: 'drawername',
mapping:1
}
]
}, cfg));
}
});
new dsjson_drawers();


{
xtype: 'listview',
columnResize: false,
store: 'dsjson_drawers',
hideHeaders: true,
simpleSelect: true,
singleSelect: true,
id: 'list_group',
columns: [
{
xtype: 'lvcolumn',
header: 'Name',
dataIndex: 'drawername'
}
]
}


Ext.getCmp('list_group').getStore().loadData(result.responseText) ;
Ext.getCmp('list_group').getStore().reload() ;
where 'result.responseText' is a json datatype like this :

{"resultat": [[8, "Oracle"], [9, "aaa"], [11, "MSSQL"]]}

any idea to refresh this content.

Condor
19 Jan 2011, 2:35 AM
Don't use autoLoad:true or reload() when you are loading local data.

Your result.responseText isn't data, it's a string!

This means you first have to convert that string to data before you can load it:

Ext.getCmp('list_group').getStore().loadData(Ext.decode(result.responseText));

jacquesh
19 Jan 2011, 2:58 AM
Works perfect !!

thanks for your help !