Results 1 to 4 of 4

Thread: <b>How can I get the Value</b>

  1. #1

    Question <b>How can I get the Value</b>

    function GetPower()
    {
    store=new Ext.data.Store({
    url:"GetPower.aspx",
    reader:new Ext.data.XmlReader({
    record:"Power"},
    [{name:"userID",mapping:"userID"},
    {name:"userName",mapping:"userName"},
    {name:"userPower",mapping:"userPower"}]
    )
    });
    store.on('load',function(){
    var power= store.getAt(0).get('userPower');
    },
    this,true);
    store.load();
    }


    How can I get the value of power in the function GetPower

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,240

    Default

    You can't, the store load is asynchronous.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

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

    Default

    Your best bet is to refactor your code so it works with asynchronous calls.

  4. #4
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996

    Default

    Maybe I misunderstood the question, but are you just looking for:

    Code:
    function GetPower(){
        
        var store = new Ext.data.Store({
            url: "GetPower.aspx",
            reader: new Ext.data.XmlReader({
                record: "Power"
            }, [{
                name: "userID",
                mapping: "userID"
            }, {
                name: "userName",
                mapping: "userName"
            }, {
                name: "userPower",
                mapping: "userPower"
            }])
        });
        
        store.on({
            load:{
                fn: function(){
                    var power = store.getAt(0).get('userPower');
                },
                scope: this
            }
        });
        
        store.load();
    }

Posting Permissions

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