Second attempt at read of data source not working

2 posts, 0 answers
  1. Lisa
    Lisa avatar
    35 posts
    Member since:
    May 2011

    Posted 03 Oct 2013 Link to this post

    Hi - I have a Data Source defined for some fields on our webpage.  The first time in, it reads the data just fine.  Our users can select another value from a filter on the page, and when they click the an apply button, it should refresh the data, but it doesn't seem to do the read.  I'm not getting any errors, it just isn't doing the second read.

    Any ideas?

    kdsStudentInformation = new kendo.data.DataSource({
                transport: {  //transport: defines the URL endpoints for remote data (read/insert/update/delete)
                    read: function (options) {
                        $.getJSON(Helpers.toServicesUrl("/GetctrlEWSStudentInfoPanel"),
                            {
                                studentId: studentIDParm,  //935824
                                username: WSIPCContext.UserName,
                                schoolCode: schoolCodeParm,
                                schoolYear: schoolYearParm,
                                districtId: WSIPCContext.DistrictId
     
                             },
                             function (data) {
                                stuInfox = data.GetctrlEWSStudentInfoPanelResult.RootResults;
                                kdsStudentInformation.data(stuInfox);
                                loadStudent();
     
                            }).fail(function (jqXHR) {
                                options.error(jqXHR);
                            });
                        //read               
                    }, //transport
                    schema: { //tells the Data Source where to find the result set
                        data: "stuInfox"
                    }
               });

    And to read it:

    kdsStudentInformation.read();

    thanks!
  2. Lisa
    Lisa avatar
    35 posts
    Member since:
    May 2011

    Posted 03 Oct 2013 Link to this post

    Interesting.  I modified my data Source code to look like this, and it looks like it's working:

    //DataSource for Student Information
    kdsStudentInformation = new kendo.data.DataSource({
        transport: {
            read: function (options) {
                if (!(kdsStudentInformation)) {
                    options.success([]);
                    return;
                }
                $.getJSON(Helpers.toServicesUrl("/GetctrlEWSStudentInfoPanel"),
                {
                    studentId: studentIDParm,  //935824
                    username: WSIPCContext.UserName,
                    schoolCode: schoolCodeParm,
                    schoolYear: schoolYearParm,
                    districtId: WSIPCContext.DistrictId
     
                }).success(function (data) {
                    options.success([]);
                    stuInfox = data.GetctrlEWSStudentInfoPanelResult.RootResults;
                    loadStudent();
     
                });
            }
        }
    });
  3. Kendo UI is VS 2017 Ready
Back to Top