1. #1
    Sencha User
    Join Date
    Nov 2009
    Posts
    14
    Vote Rating
    0
    dcipher is on a distinguished road

      0  

    Question Json Data Store Questions

    Json Data Store Questions


    Hi

    I am attempting my first extJS applications so this is basically a learning project. I have attached a file containing a short example where I want to load a listview from a json data store. The listview is rendered by without showing any rows. It does correctly call the url and data is returned. So I have the following questions:

    1) How should the params object be configured that is passed to the store load() method?
    2) Are the name/value a pairs in the params object just turned into query string parameters
    3) Do I required a callback function to load the listview or is that done automatically? If it is not done automatically how should it be done?

    Thanks
    Simon
    Attached Files

  2. #2
    Sencha User
    Join Date
    Mar 2008
    Posts
    74
    Vote Rating
    0
    piyushjain7 is on a distinguished road

      0  

    Default


    Your code looks ok. I think the only problem is in the width you specified for the columns, 0.2 and 0.3 doesn't make sense. Rather try 100, 200.

  3. #3
    Sencha User
    Join Date
    Nov 2009
    Posts
    14
    Vote Rating
    0
    dcipher is on a distinguished road

      0  

    Default


    The column widths are correct because they are supposed to be expressed as a percentage of the total width so .2 represents 20% and the .8 represents 80%. I could have left one column undefined and it would automatically be assigned the remainder.

    So something else is missing in my code.

    Simon

  4. #4
    Sencha User
    Join Date
    Jul 2009
    Location
    The Netherlands
    Posts
    196
    Vote Rating
    0
    nicobarten is an unknown quantity at this point

      0  

    Default


    guess you need also 'totalProperty' in your jsonStore like this:

    Code:
    var upmenu_json = new Ext.data.JsonStore({
                    url: 'http://localhost/cisaa/loadmenu.dcjs?',
                    root: 'rows',
                    totalProperty: 'total',
                    fields: ['id','no','item', 'desc']
                });
    Then you can use the following Json:

    {"total":"2","rows":[{"id":"1","no":"15","item":"item1","desc":"description1"},{"id":"2","no":"16","item":"item2","desc":"description2"}]}

    In 'total' you set how many rows you give to the store.

  5. #5
    Sencha User
    Join Date
    Nov 2009
    Posts
    14
    Vote Rating
    0
    dcipher is on a distinguished road

      0  

    Default Re: Json Data Store Questions

    Re: Json Data Store Questions


    The totalProperty makes no difference. So something else is wrong.

    Simon

  6. #6
    Sencha User carol.ext's Avatar
    Join Date
    Jun 2007
    Location
    Littleton, Colorado, USA
    Posts
    698
    Vote Rating
    28
    carol.ext has a spectacular aura about carol.ext has a spectacular aura about

      0  

    Default


    Is the json coming from a different domain? If not, why are you not using a relative url? If so, you'll need to use ScriptTagProxy. Read the doc carefully!

    Added note: next time just post your code in code tags, you will get more people looking at it; the Help Guide describes how to do it.

  7. #7
    Sencha User
    Join Date
    Nov 2009
    Posts
    14
    Vote Rating
    0
    dcipher is on a distinguished road

      0  

    Default


    I am not using relative url for the data if that is what you are referring to.

    I am using relative URL for the javascript files because my application will be used by a number of clients on different servers so the url might be different but the application structure will always be the same.

    For test purposes I was using FireFox to open the Index.htm file from the file system instead of using a http request.

    I will setup a test website and see if there is any difference.

    Thanks for the tip about code tags.

    Simon

  8. #8
    Sencha User carol.ext's Avatar
    Join Date
    Jun 2007
    Location
    Littleton, Colorado, USA
    Posts
    698
    Vote Rating
    28
    carol.ext has a spectacular aura about carol.ext has a spectacular aura about

      0  

    Default


    Quote Originally Posted by dcipher View Post
    I am not using relative url for the data if that is what you are referring to.
    ...
    For test purposes I was using FireFox to open the Index.htm file from the file system instead of using a http request.
    Yes, that would be a problem.

  9. #9
    Sencha User
    Join Date
    Nov 2009
    Posts
    14
    Vote Rating
    0
    dcipher is on a distinguished road

      0  

    Default [Solved] Json Data Store Questions

    [Solved] Json Data Store Questions


    I changed my setup so that I actually load the page using a http request in the browser and everything works perfectly. So the problem was due to cross domain urls.

    Thanks for pointing me in the right direction regarding the cross domain urls.

    Simon