My json data looks like this :
Code:
({"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":"combobox" 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 :
Code:
myStore.load({
scope: this,
callback : function(record, operation, success) {
console.log(record);
console.log(record.data);
}
And :
Code:
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 :
Code:
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.
My store looks like this :
Code:
Ext.define('Metrics.store.MyStore', {
extend: 'Ext.data.Store',
model: 'Metrics.model.MyModel',
autoLoad: true,
idProperty: 'id_metric',
proxy : {
type : 'ajax',
node : 'id_metric',
api : {
read : 'gui_comp_items.php'
},
reader: {
type: 'json',
successProperty: 'success',
messageProperty: 'message',
root: 'data'
}}
});
My model :
Code:
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'}]
});
Pleaaase try to help me on this one, thank you!