tags:

views:

75

answers:

1

i have a json store loaded , i need to grab one record from it i used ; getAt(index) , find() , getById() , but no results this is my code :

var appSettingReader = new Ext.data.JsonReader({     
                root: 'results',
              },[
                {name: 'id', type: 'int', mapping: 'id'},
                {name: 'projetId', type: 'int', mapping: 'projetId'},
                {name: 'resLevels', type: 'int', mapping: 'resLevels'},
                {name: 'maxResToLock',  type: 'int', mapping: 'maxResToLock'},
                {name: 'maxTimeToLock', type: 'int', mapping: 'maxTimeToLock'},
                {name: 'infosToPrint', type: 'string', mapping: 'infosToPrint'}
              ])

var appSettingStore = new Ext.data.Store({
                proxy: new Ext.data.HttpProxy({
                        url: 'inc/getSettings.php',
                        method: 'POST'
                    }),
                baseParams:{task: "app"}, 
                reader : appSettingReader,
                sortInfo:{field: 'id', direction: "DESC"}
               })

appSettingStore.load(); 

this code return undefined :

console.log(appSettingStore.getAt(0));

console.log(appSettingStore.find("id","1")); 

this is the json string returned from server :

{success:true,"results":[{"id":"1","projetId":"1","resLevels":"1","maxResToLock":"40","maxTimeToLock":"10","infosToPrint":"1_2_3_5","hotlineMail":"[email protected]"}]}

i've also test this code :

var records = new Array()       
var test = appSettingStore.each(function(rec){
            records.push(rec)
         })
console.log(records)

and i get an empty array !

PS : this store is not binded to any component i just want to read and write to it

A: 

It appears the server is returning invalid JSON. Why does your server-side script's output start with "("?

If that's not actually the problem, maybe you should consider accepting some more answers to your questions. People will be more likely to help.

EDIT: Okay, so you're pretty sure you're getting valid json back from the server. Try adding a 'success' property to your server's output.

If that doesn't work, you'll want to dig in a little more. Try adding a callback option to your store's .load(), and look at the stuff that gets passed into the callback. That should help you figure out where things are going wrong.

timdev
no its not that the problème , thank you iam waiting for more answers
cranberies
there is no issue in the stor it load fine , i can bind it with a grid i dont know where is the probleme , i cant use store methodes to find records
cranberies