Results 1 to 6 of 6

Thread: Getting data for several JsonStores with one request

  1. #1
    Sencha User
    Join Date
    Jan 2011
    Posts
    8

    Default Getting data for several JsonStores with one request

    Hi there!

    I have a locigal question. I tried and searched now for several days and it doesn't work. Perhaps someone in the forum can help me out.

    I want to load some data for a histogram chart from a database. The execution time of the query can be pretty high. That's why I want to get all data from my model and not only the bars.

    What kind of information do I collect?

    1: The histogram itself. Some like
    {"Dauer":0,"Anzahl":1},{"Dauer":2,"Anzahl":1},{"Dauer":18,"Anzahl":3} ...
    2. Data to specify the histogram
    StartDate,
    EndDate,
    MinDauer,
    MaxDauer
    Stepwidth
    I had the idea to embed the different results into one resultset, like
    PHP Code:
    {"total":4,                               //totalProperty of general request
     
    "result":                                //root of general
        
    {"histogramm":[                       //root of histogram
             
    {"Dauer":0,"Anzahl":1},
             {
    "Dauer":2,"Anzahl":1},
             {
    "Dauer":18,"Anzahl":3}],
         
    "totalbars":3,                       //totalProperty of histogram
         
    "formdata":                          //root of form data
             
    {"StartDate":-1,
              
    "EndDate":-1,
              
    "MinDauer":1.97,
              
    "MaxDauer":20.20,
              
    "Stepwidth":2.53
             
    },
         
    "totalform":5                        //totalProperty of form data
        
    }

    I tried to load all data by one JsonStore and to distribute the collected data to specialiced JsonStores.

    PHP Code:
        var histogrammstore = new Ext.data.JsonStore({
            root: 'histogramm',
            totalProperty: 'totalbars',
            fields: ['Dauer', 'Anzahl']
        });
        
        var formstore = new Ext.data.JsonStore({
            root: 'formdata',
            totalProperty: 'totalform',
            fields: ['StartDate','EndDate','MinDauer','MaxDauer','Stepwidth']
        });
        
        var generalstore = new Ext.data.JsonStore({
            root: 'result',
            totalProperty: 'total',
            url: '<?php echo url_for('modul/HistogrammSQL?id='.$modul->getId()) ?>',
            autoLoad: true,
            fields: ['histogramm', 'totalbars', 'formdata', 'totalform'],
            listeners: {
                load: function ()
                {
                    var data = generalstore.reader.jsonData;
                    histogrammstore.loadData(data); //********* ERROR ***********
                    formstore.loadData(data);
                }

            }
        });

        ... (other code)
    Everything works fine until the execution reached the line marked with "ERROR".

    Firebug delivers the message:

    root is undefinedvar root = this.getRoot(o), c ...th, totalRecords = c, success = true;

    I have tried a lot of other combinations of these datasets without success. Can anyone of you tell me if this kind of behaviour is realizable?

    I'm using ExtJS 3.3.1.

    Thanks in advance!

    Peter

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    I think that generalstore.reader.jsonData; points to generalstore's root. That's most likely why you're getting the exception. A simple breakpoint would do the trick here.

  3. #3
    Sencha User
    Join Date
    Jan 2011
    Posts
    8

    Default

    Hi jgarcia!

    Thanks for your reply.

    I think that generalstore.reader.jsonData; points to generalstore's root.
    That's exactly my thought. Generalstore's root is "result" and so these are my 4 datasets for histogram and form.
    I already tried to read the raw data at that point, but I wasn't able to find a method to access the data.

    Peter

  4. #4
    Sencha User
    Join Date
    Jan 2011
    Posts
    8

    Default

    Isn't there anybody to help me?

  5. #5
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    if you're going to go through that trouble, why not just use an ajax request, which loads all the stores with the inbound payload?

  6. #6
    Sencha User
    Join Date
    Jan 2011
    Posts
    8

    Default

    If I understand you right you mean that an ajax request should activate all stores to load the data.

    The problem here is that each request has it's own database connection. So I would have to do the query another time.

    Meanwhile I realized it via session handling, but it's not so nice...

Similar Threads

  1. Split JSON into 2 JsonStores
    By guys2008 in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 20 Nov 2010, 8:01 AM
  2. [FIXED-196] JsonStores broken in 0.9.3 (maybe 0.9.2 as well)
    By jeroenvduffelen in forum Sencha Touch 1.x: Bugs
    Replies: 5
    Last Post: 4 Sep 2010, 1:24 PM
  3. Comparing 2 JsonStores
    By nicosk in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 20 Jul 2010, 2:11 PM
  4. Compare data from 2 JsonStores and highlight differences?
    By walkman50 in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 4 May 2009, 12:32 PM
  5. Reusing one call for several JsonStores
    By fgerneth in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 19 Oct 2008, 10:16 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
  •