Results 1 to 4 of 4

Thread: How to load the store from a form load xml response...help me please

  1. #1
    Sencha User
    Join Date
    May 2011
    Posts
    2

    Default How to load the store from a form load xml response...help me please

    Hi everyone,I'm a newbie,i've just searching about ExtJS so i have problem to load a store from XMLresponse

    This is the responseXML when i click the button "test" :

    <?xml version='1.0' encoding='utf-8'?>
    <dataset>
    <row><gid>1</gid><id_huyen>697</id_huyen><danso>62113</danso></row>
    ..............................................................................................................
    <row><gid>10</gid><id_huyen>697</id_huyen><danso>62113</danso></row>
    </dataset>

    Button text :
    action = new GeoExt.Action({
    text: 'test',
    name: 'abc',
    handler: function(){
    var result ;
    OpenLayers.loadURL("./connect.jsp",result,this,test,test);
    function test(response){
    if(response && response.responseText){
    //alert(response.responseText);
    var XMLStore=response.responseText;
    alert(XMLStore);
    }
    else{
    alert("wrong");
    }

    }
    }
    //------> What i continue to do to setup a XMLStore to the GridPanel

    });

    And this is the GridPanel i using the XML:

    var grid = new Ext.grid.EditorGridPanel({
    store: XMLStore,
    columns: [
    {header: "GID", dataIndex: 'gid'},
    {header: "HUYEN", dataIndex: 'id_huyen'},
    {header: "DANSO", dataIndex: 'danso'},
    ]
    });

  2. #2

    Default

    i would say, you need a store with a reader wihch contains what you need for the columns.

    that means:

    var XMLStore = new Ext.data.Store({
    url: 'xmlStore.xml',
    reader: new Ext.data.XmlReader({
    record: 'dataset',
    id:'gid'
    },[
    '',
    'id_huyen',
    'danso'
    ]),
    groupField:'size',
    sortInfo:{field:'name', direction:'ASC'},
    remoteSort: true,
    autoLoad: true
    });

    im not sure what you exatly want to do with this button but a grid needs a reader, store and a url.

  3. #3
    Sencha User
    Join Date
    May 2011
    Posts
    2

    Default

    Thanks for reply
    I mean that,i want when i click the button the XMLreponse will load into the Grid,but i don't have a XML file,the XML is the reponse from the server.
    I understand your answer but my problem is "the XML is the reponse from sever" not "a file",please help me

  4. #4
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791

    Default

    To load data from the server you just need to set the url config option on your store. e.g.:

    Code:
    var store = new Ext.data.XmlStore({
       url: './connect.jsp',
        ...
    });
    This will create an HttpProxy that loads the XML from the server by calling connect.jsp over Ajax. See the ExtJS docs for more.

Posting Permissions

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