Results 1 to 4 of 4

Thread: [Noob Question] Send complex Object to JSON Store

  1. #1
    Sencha User
    Join Date
    Feb 2011
    Location
    Dsseldorf, Germany
    Posts
    594
    Vote Rating
    33
      0  

    Question [Noob Question] Send complex Object to JSON Store

    Hi there,

    I receive a Json object from the server and now I need to create a store for this.
    But the object is quite complex and I need a starting point how to think, to solve this.
    How would the model and store would look like so that I can add Ajax.Object in there?
    Can you give me an example to the following structure:

    Code:
    Object
        IsSearch: true
        MyGames: Array (25)
            0: Object
                storedInFolder: 3
                Game: Object
                    jumps: false
                    runsOn: Object
                        Win: "007"
                        Max: false
                    details: Object
                        howGood: "10/10"
                        publishingDate: "12.12.1982"
                    stillAvailable:false
            1: Object
                storedInFolder: 3
         ... (and so on)
    I have mainly problems with the objects inside the object and how to show this inside the model for the store. Here is a try, which did not work:

    Code:
    Ext.regModel('ajaxObject.model', {
        fields: [
            'storedInFolder',
                'Game',
                    'jumps',
                    'runsOn',
                        'Win',
                        'Max',
                    'details',
                        'howGood',
                        'publishingDate',
                    'stillAvailable'
        ]
    });
    Please let me know how to set up the model.

  2. #2
    Sencha Premium Member
    Join Date
    Sep 2008
    Posts
    710
    Vote Rating
    6
      0  

    Default

    Not sure a model is the way to go when your JSON object is that nested. You might be better manually pulling down the object and loading into the store, something like this:

    Code:
            Ext.Ajax.request({
                url: 'url/getData',
                params: {
                    param1: 'someValue' 
                },
                success: function (response, opts) {
                    // Decode the response into a JSON object
                    jsonResponse = Ext.decode(response.responseText);
    
                    var store = Ext.getCmp('yourStoreId');
                    // OR if store is configured with 'storeId' property, you can use 
                    // store = Ext.StoreMgr.lookup('storeId');
    
                    // Ensure you have results
                    if (jsonResponse.results) {
                        if (jsonResponse.results.length > 0) {
                            store.loadData(jsonResponse.results, false);
                    .....
    Give that a shot, hopefully it gets you pointed in the right direction.

  3. #3
    Sencha User
    Join Date
    Jul 2011
    Posts
    2
    Vote Rating
    0
      0  

    Default

    Hi,
    I have an issue with Json query.
    I am using Javascript, json and dojo for display. I have a grid where i display a set of records. I have filter option where i can customize by giving my own filter. If i give constructing json query like != as <> and *a* , it is working fine.
    My requirement is filter should also work for !=*a* which means it should return string which doesnt have letter 'a'.

    Please help me in achieving the same..Thanks.

  4. #4
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Location
    Italy
    Posts
    1,395
    Vote Rating
    24
      0  

    Default

    Hi Kurt001.
    You can do it without problem with model definition and associations.
    Post me the json you want lo load (just give me one or two elements for big array) and I will write you an example on how to do it.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    Owner at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    https://github.com/AndreaCammarata/TUX


Similar Threads

  1. TabBars and iconCLS (just another newbie noob noob question)
    By StayArrr in forum Sencha Touch 1.x: Discussion
    Replies: 0
    Last Post: 13 Feb 2011, 1:21 AM
  2. Send JSON object to PHP
    By slckysr in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 15 Jan 2011, 5:42 PM
  3. Complex json object into a GridPanel
    By MmarcoM in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 24 Aug 2009, 7:33 AM
  4. How send complex data in JSON
    By vsanchez in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 3 Jul 2008, 5:04 AM

Posting Permissions

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