Accessing datasource items not working

2 posts, 0 answers
  1. Brian
    Brian avatar
    2 posts
    Member since:
    Sep 2012

    Posted 10 Dec 2012 Link to this post

    Hello, I am trying to access my datasource after I read it in remotely.  The problem is that it thinks that my datasource is undefined.  I am pretty sure I am using the proper syntax because when I check the data in the change() event, it shows all the data correctly and I can access each field.  But when i try to do it outside of the code it doesn't work.  Here is my code and the errors I am getting.  PLEASE HELP!

    PlayerCalculatorModule.prototype.initialize = function() {
        'use_strict';
        var self = this;
        var calcData;
        this.eventModel = kendo.data.Model.define({
            id: "playerGUID",
            playerFirstName: "playerFirstName",
            playerLastName: "playerLastName",
            pricePerTd: "pricePerTd",
            pricePerYard: "pricePerYard",
            pricePerFumble: "pricePerFumble",
            pricePerSacked: "pricePerSacked",
            pricePerIncompletion: "pricePerIncompletion",
            pricePerInterception: "pricePerInterception",
            pricePerCompletetion: "pricePerCompletetion",
            playerStartingPrice: "playerStartingPrice"
        });
        this.calcData = new kendo.data.DataSource({
            transport: {
                read: {
                    // the remote service url
                    url: "/Market/ServiceBeans/playerCalcService.jsp",
                    // JSONP is required for cross-domain AJAX
                    dataType: "json",
                    // additional parameters sent to the remote service
                    data: { //additional parameters sent to the remote service
                        action: "getEvents"
                    }
                }
            },
            change: function () { // subscribe to the CHANGE event of the data source
                console.log(this.data());
            }
        });
        this.calcData.read();
        console.log(this.calcData.data());

    };

    The first time I call console.log(this.data());  Everything works as it should.  But when i call :
     console.log(this.calcData.data()); It thinks i have no data.  

    Here are is the console output:

    [_eventsObject]
    1. _eventsObject
    2. length0
    3. parentfunction (){return t._parent()}
    4. typefunction (e){var t,n,i,r=this,a=function(){return r};U.fn.init.call(this);for(n in e)t=e[n],"_"!=n.charAt(0)&&(i=ft.call(t),t=r.wrap(t,n,a)),r[n]=t;r.uid=L.guid()}
    5. __proto__Class.extend.i
    ^^^^^ This is the bad return, it should have a length of not 0

    [U.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.initU.extend.init]
    1. [0 … 99]
    2. [100 … 168]
    3. _eventsObject
    4. length169
    5. parentfunction (){return t._parent()}
    6. typefunction (e){var t,n,i,r=this,a=function(){return r};U.fn.init.call(this);for(n in e)t=e[n],"_"!=n.charAt(0)&&(i=ft.call(t),t=r.wrap(t,n,a)),r[n]=t;r.uid=L.guid()}
    7. __proto__Class.extend.i

    ^^^^^ This is the correct output it has all of my objects and their fields within each.

    Any help is greatly appreciated, I am really stuck on this one.

  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 12 Dec 2012 Link to this post

    Hello Brian,

    I tried your code and it seems to be working properly after calling the initialize method.

    Here is a jsbin:

    http://jsbin.com/edamuj/129/edit

    Kind Regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top