Results 1 to 3 of 3

Thread: updating data on button click

  1. #1
    Ext User
    Join Date
    Jun 2009
    Location
    guthrie Ky
    Posts
    39

    Default updating data on button click

    I have a an extension to an xml datastore:

    MyStore = Ext.extend(Ext.data.XmlStore, {
    constructor: function(cfg) {
    cfg = cfg || {};
    MyStore.superclass.constructor.call(this, Ext.apply({
    storeId: 'MyStore',
    url: 'http://maps.google.com/maps/api/geocode/xml?address=37043&sensor=false',
    record: 'address_component',
    autoLoad: true,
    autoDestroy: true,
    fields: [
    {
    name: 'long_name'
    },
    {
    name: 'short_name'
    },
    {
    name: 'type'
    }
    ]
    }, cfg));
    }
    });
    new MyStore();

    Later in my app I want the user to be able to change the zip code in the call to google api

    {
    xtype: 'panel',
    height: 87,
    layout: 'auto',
    items: [
    {
    "xtype": "textfield",
    "id" : "zipgetter",
    "fieldLabel": "Zip Code:",
    "width": 200
    },
    {
    "xtype": "button",
    "text": "Get lat/lng",
    "width": 200,
    handler: function(){
    var v = Ext.get('zipgetter').getValue();
    //var lastOptions = MyStore.lastOptions;
    //Ext.MessageBox.alert(MyStore);
    //Ext.apply(lastOptions.params, {
    // url:'http://maps.google.com/maps/api/geocode/xml?address='+v+'&sensor=false'
    //});
    //MyStore.reload(lastOptions);
    MyStore.reload({params:{url:'http://maps.google.com/maps/api/geocode/xml?address='+v+'&sensor=false'}});
    }

    }
    ]
    }

    any help would be appreciated.
    james Smith
    web data worx
    [email protected]

  2. #2
    Sencha User
    Join Date
    Sep 2009
    Location
    Calgary, Alberta, Canada
    Posts
    638

    Default

    Notice how hard it is to read this post. Please apply some CODE tags, and read this first. You can edit your original post to see if you would get a better response.

    Luckily it's pretty straightforward code.

    It would be preferable if you used:
    Code:
    url: "http://maps.google.com/maps/api/geocode/xml"
    baseParams: {
        sensor: false
        address: 37043
    }
    Later, you can use:
    Code:
    MyStore.load({
        params: {address: v}
    }
    In case "v" ever needed to be urlEncoded, you would have to do this, however in the above code, there is no need.

  3. #3
    Ext User
    Join Date
    Jun 2009
    Location
    guthrie Ky
    Posts
    39

    Default Perfeck thanks

    Also will do on the code marking.
    james Smith
    web data worx
    [email protected]

Similar Threads

  1. Refreshing Grid Data on Button Click where store is in separate js file
    By progress2 in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 17 Apr 2010, 4:15 PM
  2. Tab contents not updating without mouse click
    By vabenzo in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 21 Oct 2009, 2:24 PM
  3. How to get Row data in grid on click of button present inside Grid
    By gnaigaonkar in forum Ext GWT: Discussion
    Replies: 0
    Last Post: 24 Jun 2009, 9:17 AM
  4. Problem loading a Grid with server data on click of a button
    By blueboy in forum Ext 2.x: Help & Discussion
    Replies: 11
    Last Post: 10 Apr 2008, 1:22 PM
  5. Updating a Panel on Node Click
    By wekkaw in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 18 Jan 2008, 1:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •