my json data looks like this :
({"success": "true", "message" : "OK","data":[{"id_metric":"1","name_filter":"doc filter","type_guicomp":"combobox"},{"id_metric":"1","name_filter":"severity","type_guicomp":"combobox"}]})
I'd like to be able to retrieve the "type_guicomp"
field value for the "id_metric" = 1
, so the result would be : "type_guicomp":"combobox"
and "type_guicomp":"combobox"
.
I do this because I need the value "combobox"
to assign it to a variable.
I've tried several things including :
myStore.load({
scope: this,
callback : function(record, operation, success) {
console.log(record);
console.log(record.data);
}
And :
var index = Ext.StoreMgr.lookup("myStore").findExact('id_metric',1);
var rec = Ext.StoreMgr.lookup("myStore").getAt(index);
console.log(rec);
These solutions return undefined or null. So when I did this in the callback :
var i = myStore.getCount();
console.log(i);
It returned 0
. But when I check the json output, it's not empty and there's actually data in it.
What am I doing wrong? Please any help would be appreciated.
EDIT
My store looks like this :
Ext.define('Metrics.store.MyStore', {
extend: 'Ext.data.Store',
model: 'Metrics.model.MyModel',
autoLoad: true,
idProperty: 'id_metric',
proxy : {
type : 'ajax',
actionMethods : 'POST',
node : 'id_metric',
api : {
read : 'gui_comp_items.php' //the php script that gets data from db
},
reader: {
type: 'json',
successProperty: 'success',
messageProperty: 'message',
root: 'data'
}
}
});
My Model :
Ext.define('Metrics.model.MyModel', {
extend: 'Ext.data.Model',
fields: [
{name : 'id_metric', type : 'int'},
{name : 'name_filter', type : 'string'},
{name : 'type_guicomp', type : 'string'},
{name : 'value', type : 'string'}]
});