January 5th, 2009 Help with Data Store

  • I am new to javascript/Ext js
    I am trying to populate a google map with markers about 200, using data store.
    If i load the data to a GridPanel the data shows with no problem.
    But if I try as indicated below. The line "var count = store.getCount();"
    Gets skipped or returns a zero.
    If I put break on it (using firebug) and step through. everything loads corectly!!!
    What could be causing this behavior?
    Any pointers are appreciated


    //********************************************
    // create the Data Store
    store = new Ext.data.Store({
    // load using HTTP
    proxy: new Ext.data.HttpProxy({
    url: 'http://localhost/DataStream.aspx',
    method: 'POST',
    listeners: {
    loadexception: function(proxy, store, response, e) {
    alert(e.message);
    }
    }
    }),
    // the return will be XML, so lets set up a reader
    reader: new Ext.data.XmlReader({
    // records will have an "Item" tag
    record: 'GeoData',
    id: 'HOSPITAL_ID',
    totalRecords: '@total'
    },
    [
    // set up the fields mapping into the xml doc
    // The first needs mapping, the others are very basic
    {
    name: 'HOSPITAL_NAME',
    type: 'string',
    mapping: 'HOSPITAL_NAME'
    },
    {
    name: 'ACRONYM',
    type: 'string'
    },
    {
    name: 'LAT',
    type: 'string'
    },
    {
    name: 'LON',
    type: 'string'
    }])
    });

    store.on('loadexception',
    function() {
    alert("load exception")
    });

    store.load({
    params: {
    'testing',
    'testing'
    }
    });

    var LoadingM = new Ext.LoadMask('map', {
    text: 'Initializing...'
    });

    var markersArray=;
    LoadingM.enable();

    //Suspect line
    var count = store.getCount();

    if(count > 0){
    LoadingM.show();
    store.each(function(r) {
    // dataTest = r;
    var lat = parseFloat(r.get('LAT'));
    var lon = parseFloat(r.get('LON'));
    if (isNaN(lat) isNaN(lon)) {} else {
    var marker = createMarker(lat, lon);
    //map.addOverlay(marker);
    markersArray.push(marker);
    }

    //return false;
    });
    var cluster=new ClusterMarker(map, { markers:markersArray } );
    cluster.fitMapToMarkers();
    }

    LoadingM.hide();


  • Thank you:D/


  • store load operations (as with all ajax transactions) happen asynchronously. in order to access your data, you will have to do it in a load event handler.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Help with Data Store , Please add it free.