samedi 11 avril 2015

using model and store

Hello guys, am new to extjs ,

am confused a bit using the model, store and proxy.. here is my code, any help would be highly appreciated :)



the model :



Ext.define('frontend.model.Student' , {

extend: 'Ext.data.Model',
fields: [

'id' , 'firstName' , 'lastName' , 'birthDate' , 'password' , 'grade'
]



});

store for CRUD :



Ext.define('frontend.store.Student' , {

extend: 'Ext.data.Store',
model: 'frontend.model.Student',
storeId: 'Student',
proxy: {

type: 'rest',
url: 'http://ift.tt/1FKqnOJ',
reader:{

type: 'json'
},
writer: {type:'json'}

}

});store for the students list :



Ext.define('frontend.store.AllStudents' , {

extend: 'Ext.data.Store',
model: 'frontend.model.Student',
proxy: {

type: 'ajax',
url: 'http://ift.tt/1yfCB1E',
reader:{

type: 'json'
}

},
autoLoad: true

});


data comes from the http://ift.tt/1yfCB1E url looks like :





[{"id":"1","firstName":"Mohannad","lastName":"Saidi","birthDate":1427214056834,"password":"new Password","oldPassword":null,"grade":null},{"id":"3","firstName":"Mothanna","lastName":"Basheir","birthDate":1427215484870,"password":"default","oldPassword":null,"grade":null}]when i try to retrieve any record, it says that the record is null :(





var store = Ext.create('frontend.store.AllStudents');
store.load();
var user = store.findRecord('firstName', 'Mohannad');
console . log (user. getData ()) ;



how can i get the data from the store ?

am using Extjs 5.0.1

thanks in advance :D





using model and store

Aucun commentaire:

Enregistrer un commentaire