1. #1
    Sencha User
    Join Date
    Sep 2011
    Location
    Sallanches, France
    Posts
    371
    Vote Rating
    1
    myput is on a distinguished road

      0  

    Default Pass Variable store to Url Store

    Pass Variable store to Url Store


    Hello,

    I Have a store with extraParams who contain an ID. I would like to pass the ID at the end of the url store.
    I have:
    Code:
    WPApp.stores.DirectoryCategoryListStore = new Ext.data.Store({
        model: "WPApp.models.DirectoryCategoryListModel",
        proxy: {
            type: 'ajax',
            url: "http://localhost:8888/WPapp/app/php/getCategoryList.php",
            reader: {
                type: 'json'
            }
        },
        setId: function (id) {
            this.itemId = id;
        },
        extraParams: {
            id: this.itemId,
        },
        autoLoad: true
    });
    I would like to have if this.itemId = 2
    HTML Code:
    url: "http://localhost:8888/WPapp/app/php/getCategoryList.php?id=2"
    when i put the url like that with raw values, it's working.
    i tried to concat the variable to URL, and create a new extra param with the url, but don't work.

    In my PHP file, the URL, i have:
    Code:
        $id = $_GET['id'];
        $request = "SELECT * FROM CategoryList WHERE IDBASELIST = $id";
        echo (getJsonString($request, $dbName));
    I don't really understand how i can give this extra Params to my URL
    Someone can help me please?

  2. #2
    Sencha User
    Join Date
    Sep 2011
    Location
    Zürich, Switzerland
    Posts
    19
    Vote Rating
    0
    katamshut is on a distinguished road

      0  

    Default


    you should check what url your browser sends to the server. it is easy to check with chrome (debug mode).

    and for your problem try to do like this:

    Code:
    WPApp.stores.DirectoryCategoryListStore = new Ext.data.Store({
        model: "WPApp.models.DirectoryCategoryListModel",
        proxy: {
            type: 'ajax',
            url: "http://localhost:8888/WPapp/app/php/getCategoryList.php",
            reader: {
                type: 'json'
            },
            extraParams: {
                id: this.itemId,
            }
        },
        setId: function (id) {
            this.itemId = id;
        },
        autoLoad: true
    });
    extraParams cannot be a part of Ext.data.Store. It is a part of the Ext.data.Proxy class.

  3. #3
    Sencha User
    Join Date
    Sep 2011
    Location
    Sallanches, France
    Posts
    371
    Vote Rating
    1
    myput is on a distinguished road

      0  

    Default


    Okey,
    First thanks for your answer,


    I corrected the code and put Params in the proxy but no work.
    i try to read the JS debuger in chrome,

    it say:
    HTML Code:
    Refused to set unsafe header "User-Agent"sencha-touch.js:6Uncaught Ext.data.JsonReader.getResponseData: Unable to parse JSON returned by Server.Ext.data.JsonReader.Ext.extend.getResponseDatasencha-touch.js:6Ext.data.Reader.Ext.extend.readsencha-touch.js:6(anonymous function)sencha-touch.js:6Ext.data.Connection.Ext.extend.onCompletesencha-touch.js:6Ext.data.Connection.Ext.extend.onStateChangesencha-touch.js:6(anonymous function)
    Juste that i think hehe. Sorry it's the first time i use that.

    have you an Idea?

  4. #4
    Sencha User
    Join Date
    Sep 2011
    Location
    Sallanches, France
    Posts
    371
    Vote Rating
    1
    myput is on a distinguished road

      0  

    Default


    Ok i have the solution, i don't know if it's the best but it's working:

    Store:
    Code:
    WPApp.stores.DirectoryCategoryListStore = new Ext.data.Store({
        model: "WPApp.models.DirectoryCategoryListModel",
        storeId: 'DirectoryCategoryListStore',
        proxy: {
            type: 'ajax',
            url: "http://localhost:8888/WPapp/app/php/getCategoryList.php",
            reader: {
                type: 'json'
            },
        },
        setId: function (id) {
            this.itemId = id;
            WPApp.stores.DirectoryCategoryListStore.load({params:{id:this.itemId}});
        },
        autoLoad: true
    });
    Thanks for your help

  5. #5
    Sencha User
    Join Date
    Sep 2011
    Location
    Zürich, Switzerland
    Posts
    19
    Vote Rating
    0
    katamshut is on a distinguished road

      0  

    Default


    no prob.

    If this is working for you then it is ok. I tried to reproduce your problem without luck. but anyways use the chrome debugger. It is very powerful and gives you any information you need. If you really want to know whats wrong then you have to debug sencha code. Therefore use the sencha-touch-debug-w-comments.js to debug.

    cheers
    Chris

  6. #6
    Sencha User
    Join Date
    Oct 2012
    Posts
    8
    Vote Rating
    0
    jakeed2 is on a distinguished road

      0  

    Default Success

    Success


    I needed to do this to use the ListPaging Plugin

    Add a listener to your store.. The API I call requires a token for each request. I was able to set my store with the token "beforeload" .. then when the ListPaging function is called, my token is already part of the proxy.

    Code:
    Ext.define('MyApp.store.StudentStore',{
        extend: 'Ext.data.Store',
        config:{
            storeId: 'Students',
            model:'MyApp.model.PeopleModel',
            autoLoad:false,
            clearOnPageLoad: false,
    
            listeners: {
                beforeload: function(store){
    
                    store.setProxy({
                        headers: {
                            Accept : 'application/json',
                            Authorization : 'Bearer:' + this.token
                        },
                        type: 'ajax',
                        pageParam: 'pageindex',
                        url:'https://localhost/MyApp/GetUsers.json',
                        extraParams: {
                            schoolId   : 1,
                            roleName: 'student'
                        },
                        reader: {
                            type: 'json',
                            rootProperty:'data'
                        }
                    });
                },
                load: function(store){
                    console.log(store);
                }
            },
    
            grouper: {
                groupFn: function(record) {
                    return record.get('lastname')[0];
    
                }
            },
            sorters: 'lastname'
        },
        setToken: function(token){
            this.token = token;
        }
    
    });

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar