1. #1
    Sencha User
    Join Date
    Jan 2012
    Location
    Prague
    Posts
    2
    Vote Rating
    0
    shr3k is on a distinguished road

      0  

    Default GridPanel doesn't updating after store.load() with params and add

    GridPanel doesn't updating after store.load() with params and add


    Hello, as newbie I'm apologize to disturb you with simply question, but after hours spent on FAQ, examples and API docs can't find what I'm doing wrong.

    I have a function called with "loc" parameter which on mouse click opens an anchored Ext.Window over map in Ext.Panel and relocates it with every click on map. It has configured JsonStore loading some JSON data from PHP script called with "loc" parameter:

    Code:
    {
        "_id": "f5b39dd325f55e7bce17f395dc0ed9d1",
        "expires": 1327704455,
        "type": "Feature",
        "properties": {
            "informace": {
                "parcelni_cislo": "804\/37",
                "vymera_m2": "1255",
                "katastralni_uzemi": "Ost\u0159e\u0161any 716324",
                "cislo_lv": "740",
                "typ_parcely": "Parcela katastru nemovitost\u00ed",
                "mapovy_list": "DKM",
                "urceni_vymery": "Ze sou\u0159adnic v S-JTSK",
                "druh_pozemku": "zahrada"
            },
            "vlastnici": [{
                "jmeno_nazev": "P\u00e1tek Tom\u00e1\u0161",
                "adresa": "Sadov\u00e1 323, Pardubice, Nemo\u0161ice, 530 03",
                "podil": ""
            }]
        },
        "geometry": {
            "type": "Point",
            "coordinates": [49.995131266244, 15.797092196504]
        }
    }
    This JSON should be loaded into GridPanel as single row and with every next call of function (relocating window) source PHP script should be called with "loc" parameter and fetched document should be added to the grid.

    I can open, relocate popup (extended Ext.Window), create JsonStore, create GridPanel, display first row (fetched JSON document), but can't force GridPanel to display next rows.

    In Firebug I see my store.load() function calling PHP everytime with a new "loc" parameter and getting new JSON document with new _id, but my GridPanel doesn't get updated.

    At the end I have added some debug code with box (every call adds a box with actual JSON link), but I'm surprised as store.getCount() stays at 0 all the time (even at first call). Maybe it has something to do with average 3s load time of Cadastre.php (fetches some XHTML from slow remote server, parses it to JSON document and stores in CouchDB as cached).

    Here goes my function:
    Code:
    var CadastrePopup;
    function CadastrePopupWindow(loc) {
        if (!store) {
            var store = new Ext.data.JsonStore({
                autoLoad: false,
                proxy: new Ext.data.HttpProxy({
                    url: 'Cadastre.php',
                    method: 'GET'
                }),
                idProperty: '_id',
                fields: [.....]
            });
        }
        if (!grid) {
            var grid = new Ext.grid.GridPanel({
                store: store,
                autoHeight: true,
                border: false,
                columns: [.....]
            });
        }
        if (!CadastrePopup) {
            CadastrePopup = new GeoExt.Popup({
                height: 250,
                width: 400,
                title: 'Cadastre information',
                maximizable: true,
                collapsible: true,
                map: myMap,
                anchored: true,
                listeners: {
                    close: function() {
                        CadastrePopup = null;
                    }
                },
                items: [grid]
            });
        }
        store.load({
            params: {loc},
            add: true
        });
        CadastrePopup.add({
            xtype: "box",
            autoEl: {
                html: "DEBUG: <a href=\"Cadastre.php?loc=" + loc + "\" target=\"_blank\">Link to JSON</a> Count store objects: " + store.getCount()
            }
        });
        CadastrePopup.location = loc;
        CadastrePopup.doLayout();
        CadastrePopup.show();
    }
    Do you have any advices?

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Location
    Prague
    Posts
    2
    Vote Rating
    0
    shr3k is on a distinguished road

      0  

    Default


    Solved. Sorry, this was primitive, I forgot to define my store and grid before calling the function, not in inner code as if (!Object exist) way.