1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    25
    Vote Rating
    0
    skylinezpromise is on a distinguished road

      0  

    Default extjs 4 : get store record values

    extjs 4 : get store record values


    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!

  2. #2
    Sencha Premium Member
    Join Date
    Nov 2011
    Posts
    60
    Vote Rating
    1
    avcmc is on a distinguished road

      0  

    Default


    Please share the code of creating the store too, may be issue lies there, as here you have shared the code of defining it alone.

Thread Participants: 1

Tags for this Thread