1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    5
    Vote Rating
    0
    vijaywadnere is on a distinguished road

      0  

    Question Unanswered: Single XML(Store) for multiple combos

    Unanswered: Single XML(Store) for multiple combos


    I have number of combo boxes on a FormPanel, which gets populated from an XML.

    I've all the related records (properly arranged) in a single XML.

    I've applied store: new Ext.data.XmlStore .. on each combo for same XML file on my server.

    Current behavior: the "Same" xml file loaded separately (from server) for each combo box.

    Question: Is there a way to have the XML loaded only once, and reuse the same store for different comboboxes (with different configurations, say 'readers') ?

    Code:
    <xml>
     <rootforcombo1>
      <combo1rec>
        <key>1</key>
        <value>value</value>
      </combo1rec>
      <combo1rec>
        <key>2</key>
        <value>value2</value>
      </combo1rec>
     </rootforcombo1>
     <rootforcombo2>
      <combo2rec>
        <key>1</key>
        <value>value</value>
      </combo2rec>
      <combo2rec>
        <key>2</key>
        <value>value2</value>
      </combo2rec>
     </rootforcombo2>
    </xml>
    Code:
    {
      ...
      xtype: 'combo',
     valueField: 'key',
     displayField: 'value'
     store: new Ext.data.XmlStore({
       url: "myxml.xml",
       record: 'combo1rec',
       autoLoad: true,
       idPath: 'key',
       fields: [
        {name: 'key', mapping: 'key' },
        {name: 'name', mapping: 'value'}                        
       ]   
      })
     ...
    },
    {
      ...
      xtype: 'combo',
     valueField: 'key',
     displayField: 'value'
     store: new Ext.data.XmlStore({
       url: "myxml.xml",
       record: 'combo2rec',
       autoLoad: true,
       idPath: 'key',
       fields: [
        {name: 'key', mapping: 'key' },
        {name: 'name', mapping: 'value'}                        
       ]   
      })
     ...
    }

  2. #2
    Ext JS Premium Member
    Join Date
    Dec 2010
    Posts
    18
    Vote Rating
    0
    KennethRusso is on a distinguished road

      0  

    Default


    Off the top of my head, I'd recommend:
    • Create one store manually, not as part of the configuration for the combos
    • Assign the store reference to the various combos
    • Monitor with something like firebug in firefox to ensure that the ajax call is only being made once
    Doing a "new Store()" for each combo naturally means you're creating multiple objects, which just coincidentally are looking at the same data.

  3. #3
    Sencha User
    Join Date
    Apr 2011
    Posts
    5
    Vote Rating
    0
    vijaywadnere is on a distinguished road

      0  

    Default


    Quote Originally Posted by KennethRusso View Post
    Off the top of my head, I'd recommend:

    • Create one store manually, not as part of the configuration for the combos
    • Assign the store reference to the various combos
    • Monitor with something like firebug in firefox to ensure that the ajax call is only being made once
    Doing a "new Store()" for each combo naturally means you're creating multiple objects, which just coincidentally are looking at the same data.
    Well, its not the 'exactly same store' that I'd like to use with different combos.
    I have one big XML, having multiple sections in it, I want to have multiple combos to populated by these different sections, but XML must be loaded only once.

    While scanning forums I landed on this page: http://www.sencha.com/forum/showthre...ing-with-ExtJS. This talks something close to what I need. It talks about using multiple readers. But so far I couldn't run it successfully. (May be the technique it uses is of 2.x).

  4. #4
    Ext JS Premium Member
    Join Date
    Dec 2010
    Posts
    18
    Vote Rating
    0
    KennethRusso is on a distinguished road

      0  

    Default


    I've had a similar situation where I only wanted to query for the data once and then create a variety of stores from the returned data, the whole "chunky vs. chatty" services API thing. I was using Json, which makes this pretty trivial as each store takes a "root".

    So in this particular case I called a function and passed in a callback to execute once the data was successfully loaded (see load event of Ext.data.Store). In the callback I created the remainder of the stores I needed, using the same data (rawData property of the store's reader).

    The "class" Ext.data.reader.Xml has a root configuration object so you can apply the same technique.

    Mind you I have not actually done this in 4.0, but the technique worked fine in 3.x, so I may have goofed on some specifics, but the basic idea of having one store retrieve the server data and then having the other stores created from within the load event of the store is sound. There may be much better solutions, ymmv, etc.

    Good luck.

  5. #5
    Sencha User
    Join Date
    Apr 2011
    Posts
    5
    Vote Rating
    0
    vijaywadnere is on a distinguished road

      0  

    Thumbs up [SOLVED]

    [SOLVED]


    Oops! Just now I realized that I posted my question in wrong forum. Am using 3.x, so ideally this discussion must go in 3.x. (Don't know how to move it to correct location).

    Anyways, today I tried various combination and finally managed to load single XML to create multiple store (yippie).

    Code:
                    var conn = new Ext.data.Connection;
                    conn.request({
                        url: "path-to-my-xml.xml", 
                        callback: function(options, success, response) { 
                            if (success) {                
                                var xml = response.responseXML;
                                myCallBack(xml);
                            }
                        }
                    });
    
    function myCallBack(xml) {
                      var aStore = new Ext.data.XmlStore({
                         storeId: "store-id-1",
                         record: 'record1',
                         idPath: 'key',
                         fields: [
                             {name: 'id', mapping: 'key' },
                             {name: 'val', mapping: 'value'}                
                         ],
                         data: xml
                     });
    
                    var aReader = new Ext.data.XmlReader({
                        record: 'record-2',
                        idPath: 'key',
                        fields: [
                            {name: 'key', mapping: 'key' },
                            {name: 'name', mapping: 'value'}                        
                        ]
                    });
                    
                    var store2 = new Ext.data.Store({
                        storeId: "store-id-2",
                        reader: aReader,
                        data: xml
                    });
     }
    Hope someone someday will get benefited by this.

  6. #6
    Sencha User
    Join Date
    Jan 2011
    Posts
    4
    Vote Rating
    0
    kamalt is on a distinguished road

      0  

    Default Sencha Touch 1.1 - create multiple stores with single XML reader

    Sencha Touch 1.1 - create multiple stores with single XML reader


    Hi,

    We are using Sencha Touch 1.1 and tried your approach for creating multiple stores with single XML reader. But, we are getting "Uncaught TypeError: Function.prototype.apply: Arguments list has wrong type" error.

    "data : xml" is the place where the exception is initiated.

    Could you please provide the complete working sample?

    Thanks,

    Kamal T.

Similar Threads

  1. Configuring multiple combos from single json store?
    By smick in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 17 Feb 2011, 3:50 PM
  2. Single data.Store for multiple formpanels
    By dcwmark in forum Ext 2.x: Help & Discussion
    Replies: 7
    Last Post: 13 May 2009, 12:41 PM
  3. [SOLVED] multiple combos using one filtered store
    By GTCulbreth in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 23 May 2008, 11:09 AM
  4. [2.0.2] Bug, Single store for multiple combos
    By ttp in forum Ext 2.x: Bugs
    Replies: 3
    Last Post: 26 Feb 2008, 6:31 AM
  5. Filtering a single Store for Multiple Comboboxes
    By fay in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 7 May 2007, 1:09 PM

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi