this is my code
var store = {
user_store: new Ext.data.Store({
autoLoad: false,
proxy: new Ext.data.HttpProxy({
url: 'a/b/c',
}),
remoteSort: true,
baseParams: {
},
reader: new Ext.data.JsonReader({
totalProperty: 'total',
root: 'root',
fields: ['roles']
})
})
};
store.user_store.load();
this is my json
{"roles":"2"}
I wnat to ask. How do I get the roles's value is "2".
(PS:Sorry,my English is not very well.)
Stores load data via a Ext. data. proxy. Proxy, and also provide functions for sorting, filtering and querying the Ext. data.
Built-in Events Using ListenersExt JS provides listener property for writing events and custom events in Ext JS files. We will add the listener in the previous program itself by adding a listen property to the panel. This way we can also write multiple events in listeners property.
Proxies operate on the principle that all operations performed are either Create, Read, Update or Delete. These four operations are mapped to the methods create, read, update and erase respectively. Each Proxy subclass implements these functions. The CRUD methods each expect an Ext.
If there is only one item in the response, you can add a callback function to the load method:
var store = {
user_store: new Ext.data.Store({
autoLoad: false,
proxy: new Ext.data.HttpProxy({
url: 'a/b/c',
}),
remoteSort: true,
baseParams: {
},
reader: new Ext.data.JsonReader({
totalProperty: 'total',
root: 'root',
fields: ['roles']
})
})
};
store.user_store.load(function(){
this.getAt(0).get('roles')
});
If the the response consist of several items like: [{"roles":"2"},{"roles":"1"}]
you can iterate the store to retrieve all values.
store.user_store.load(function(){
this.each(function(record){
var roles = record.get('roles');
// Do stuff with value
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With