This is a migrated thread and some comments may be shown as answers.

Accessing datasource items not working

1 Answer 100 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 11 Dec 2012, 04:36 AM
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.

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 12 Dec 2012, 03:07 PM
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!
Tags
Data Source
Asked by
Brian
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or