Data is not coming

5 posts, 0 answers
  1. Kevork
    Kevork avatar
    39 posts
    Member since:
    May 2015

    Posted 31 Mar Link to this post

    Here are my code. Job data aren't coming in scheduler. There is error in browser's console also.

     

    function recreateScheduler(groupArray, techs) {
        $("#kendoDemoScheduler").kendoScheduler({
            date: new Date("2016/3/31"),
            startTime: new Date("2016/3/31 07:00 AM"),
            height: 600,
            eventHeight: 50,
            majorTick: 60,
            views: [
                { type: "timeline", selected: true}
            ],
            timezone: "Etc/UTC",
            dataSource: {
                batch: true,
                transport: {
                    read: {
                        url: '@Url.Action("JobSchedule_Read", "JOBS")',
                        dataType: "jsonp"
                    },
                    update: {
                        url: "//demos.telerik.com/kendo-ui/service/meetings/update",
                        dataType: "jsonp"
                    },
                    create: {
                        url: "//demos.telerik.com/kendo-ui/service/meetings/create",
                        dataType: "jsonp"
                    },
                    destroy: {
                        url: "//demos.telerik.com/kendo-ui/service/meetings/destroy",
                        dataType: "jsonp"
                    },
                    parameterMap: function (options, operation) {
                        if (operation == "read") {
                            var searchCondition = "";
                            var statusCheckBoxesValues = "";
     
                            var sortFilter = $("#sortFilterDropDownList").data("kendoDropDownList").text();
                            var dispatch = $("#dispatchDropDownList").data("kendoDropDownList").value();
                            var assignto = $("#techDropDownList").data("kendoDropDownList").value();
                            var area = $("#areaDropDownList").data("kendoDropDownList").value();
                            var category = $("#categoryDropDownList").data("kendoDropDownList").value();
                            var product = $("#productDropDownList").data("kendoDropDownList").value();
                            var proditem = $("#itemDropDownList").data("kendoDropDownList").value();
     
                            var datefrom = $("#fromDatePicker").val();
                            var dateto = $("#toDatePicker").val();
     
                            if (sortFilter == "[NONE]") {
                                if (area == "[ALL]" && dispatch == "[ALL]" && assignto == "[ALL]" && category == "[ALL]") {
                                    searchCondition = "opq3";
                                }
                                else
                                    searchCondition = "opq3_1";
                            }
     
                            if (sortFilter == "Name")
                                searchCondition = "opq1";
                            else if (sortFilter == "@SystemConfiguration.AssignTo")
                                searchCondition = "opq2";
                            else if (sortFilter == "PostCode")
                                searchCondition = "opq4";
                            else if (sortFilter == "Area")
                                searchCondition = "opq5";
                            else if (sortFilter == "Suburb")
                                searchCondition = "opq6";
                            else if (sortFilter == "Job Address")
                                searchCondition = "opq8";
     
                            $(".treatmentCheckBoxes .k-checkbox").each(function (index) {
                                if ($(this).is(":checked"))
                                    statusCheckBoxesValues += $(this).attr("status") + ",";
                            })
     
                            $(".followUpCheckBoxes .k-checkbox").each(function (index) {
                                if ($(this).is(":checked"))
                                    statusCheckBoxesValues += $(this).attr("status") + ",";
                            })
     
                            if (statusCheckBoxesValues.indexOf(",") >= 0)
                                statusCheckBoxesValues = statusCheckBoxesValues.substring(0, (statusCheckBoxesValues.length - 1));
     
                            return {
                                ip_cond: searchCondition,
                                ip_area: area == "" ? "[All]" : area,
                                ip_dispatch: dispatch == "" ? "[All]" : dispatch,
                                ip_assignto: assignto == "" ? "[All]" : assignto,
                                ip_category: category == "" ? "[All]" : category,
                                ip_product: product == "" ? "[All]" : product,
                                ip_proditem: proditem == "" ? "[All]" : proditem,
                                ip_streetno: $("#txtSearchStreetNo").val(),
                                ip_filter: $("#txtSearchInput").val(),
                                ip_datefrom: datefrom == "" ? null : datefrom,
                                ip_dateto: dateto == "" ? null : dateto,
                                ip_statlist: statusCheckBoxesValues == "" ? "DB" : statusCheckBoxesValues,
                                ip_unsched: $("#unsceduledCheckBox").is(":checked"),
                                ip_contr_only: $("#contractJobsCheckBox").is(":checked"),
                                ip_quote: $("#quoteShowOnlyCheckBox").is(":checked")
                            };
                        }
                    }
                },
                schema: {
                    model: {
                        id: "ReservationID",
                        fields: {
                            taskId: { from: "ReservationID" },
                            title: { from: "Title" },
                            start: { type: "date", from: "Start" },
                            end: { type: "date", from: "End" },
                            ownerId: { from: "emm_code" }
                        }
                    }
                }
            },
            group: {
                resources: groupArray,
                orientation: "vertical"
            },
            resources: [
                {
                    field: "attendees",
                    name: "Attendees",
                    dataTextField: "TechName",
                    dataValueField: "emm_code",
                    dataSource: techs,
                    multiple: true,
                    title: "Attendees"
                }
            ]
        });
    }
     
    $(function () {
        var groupArray = ["Attendees"];
        var techs = [];
     
        $.ajax({
            async: false,
            url: '@Url.Action("Techs", "JOBS")',
            type: 'GET',
            dataType: 'json',
            success: function (data) {
                $.each(data, function (i, tech) {
                    techs.push(
                        { TechName: tech.TechName, emm_code: tech.emm_code }
                    );
                })
                recreateScheduler(groupArray, techs);
            }
        });
    })

     

    public JsonResult JobSchedule_Read([DataSourceRequest] DataSourceRequest request, string ip_cond, string ip_area, string ip_dispatch, string ip_assignto, string ip_category, string ip_product, string ip_proditem, string ip_streetno, string ip_filter, DateTime? ip_datefrom, DateTime? ip_dateto, string ip_statlist, string ip_unsched, string ip_contr_only, string ip_quote)
    {
        int jobHour = 0;
        int jobMinute = 0;
        string duration = "";
        DateTime startDateTime = ip_datefrom ?? DateTime.Now;
        DateTime endDateTime = ip_dateto ?? DateTime.Now;
        List<TaskViewModel> tasks = new List<TaskViewModel>();
     
        List<JscMstr> jscMstrs;
        List<JhMstr> jhMstrs;
        List<JdDet> jdDets;
        List<JscDet> jscDets;
        List<CoMstr> coMstrs;
        List<CodDet> codDets;
        List<JrSumm> jrSumms;
        List<CsMstr> csMstrs;
        List<HhStatus> hhStatuses;
        List<HhSumm> hhSumms;
        List<GrJscMstr> grJscMstrs;
        List<SchJsdDet> schJsdDets;
     
        List<TsMstr> tsMstr;
        JobRepository jr = new JobRepository();
     
        tsMstr = jr.GetReservations(startDateTime, endDateTime, "[ALL]");
     
        foreach (var item in tsMstr)
        {
            tasks.Add(new TaskViewModel()
            {
                TechName = item.tsm_assto,
                emm_code = item.tsm_assto,
                Title = item.tsm_reason,
                ReservationID = item.tsm_res_id,
                ReservedBy = Session["CompanyID"].ToString(),
                ReservationDate = item.tsm_res_date,
                ReservationViewDate = item.tsm_res_date.ToString("dd/MM/yyyy"),
                ReservationTime = item.tsm_res_date.ToString("dd/MM/yyyy") + " " + item.tsm_res_time,
                Start = startDateTime,
                End = endDateTime,
                Description = "Description 101",
                IsAllDay = false,
                StartViewDate = startDateTime.ToString("dd/MM/yyyy"),
                StartViewTime = startDateTime.ToString("HHmm"),
                Duration = item.tsm_job_duration,
                ScheduleType = "Reservation",
                Color = "#f8a398"
            });
        }
     
        return Json(tasks.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
    }

    Thanks.
  2. Kevork
    Kevork avatar
    39 posts
    Member since:
    May 2015

    Posted 31 Mar in reply to Kevork Link to this post

    Here is another simpler try with JSONP data.

     

    function recreateScheduler() {
        $("#kendoDemoScheduler").kendoScheduler({
            date: new Date("2016/3/31"),
            startTime: new Date("2016/3/31 07:00 AM"),
            height: 600,
            views: [
                "workWeek"
            ],
            timezone: "Etc/UTC",
            dataSource: {
                batch: true,
                transport: {
                    read: {
                        url: '@Url.Action("KendoJobSchedule_Read", "JOBS")',
                        dataType: "jsonp"
                    },
                    update: {
                        url: "//demos.telerik.com/kendo-ui/service/meetings/update",
                        dataType: "jsonp"
                    },
                    create: {
                        url: "//demos.telerik.com/kendo-ui/service/meetings/create",
                        dataType: "jsonp"
                    },
                    destroy: {
                        url: "//demos.telerik.com/kendo-ui/service/meetings/destroy",
                        dataType: "jsonp"
                    }
                },
                schema: {
                    model: {
                        fields: {
                            title: { from: "Title" },
                            start: { type: "date", from: "Start" },
                            end: { type: "date", from: "End" }
                        }
                    }
                }
            }
        });
    }
     
    $(function () {
        recreateScheduler();
    })

     

    public class JsonpResult : JsonResult
    {
        public JsonpResult()
        {
        }
     
        public JsonpResult(object Data)
        {
            this.Data = Data;
        }
     
        public override void ExecuteResult(ControllerContext ControllerContext)
        {
            if (ControllerContext != null)
            {
                HttpResponseBase Response = ControllerContext.HttpContext.Response;
                HttpRequestBase Request = ControllerContext.HttpContext.Request;
     
                //string callbackfunction = Request["callback"];
                string callbackfunction = "callback";
                if (string.IsNullOrEmpty(callbackfunction))
                {
                    throw new Exception("Callback function name must be provided in the request!");
                }
                Response.ContentType = "application/x-javascript";
                if (Data != null)
                {
                    JavaScriptSerializer serializer = new JavaScriptSerializer();
                    Response.Write(string.Format("{0}({1});", callbackfunction, serializer.Serialize(Data)));
                }
            }
        }
    }

     

    public JsonpResult KendoJobSchedule_Read([DataSourceRequest] DataSourceRequest request)
    {
        DateTime startDateTime = DateTime.Now.AddDays(-1);
        DateTime endDateTime = DateTime.Now.AddDays(-1);
        List<TaskViewModel> tasks = new List<TaskViewModel>();
     
        List<TsMstr> tsMstr;
        JobRepository jr = new JobRepository();
     
        tsMstr = jr.GetReservations(startDateTime, endDateTime, "[ALL]");
     
        foreach (var item in tsMstr)
        {
            tasks.Add(new TaskViewModel()
            {
                Title = item.tsm_reason
                , Start = startDateTime
                , End = endDateTime
            });
        }
     
        JsonpResult result = new JsonpResult(tasks);
        result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
     
        return result;
    }

     

    Here is the incoming data format for JSONP

    callback([{"Color":null,"Description":null,"End":"\/Date(1459380575560)\/","EndTimezone":null,"IsAllDay"
    :false,"RecurrenceException":null,"RecurrenceRule":null,"Start":"\/Date(1459380575560)\/","StartViewDate"
    :null,"StartViewTime":null,"StartTimezone":null,"TechName":null,"emm_code":null,"Title":"demo res","ReservationID"
    :null,"ReservedBy":null,"ReservationDate":"\/Date(-62135596800000)\/","ReservationViewDate":null,"ReservationTime"
    :null,"ReservationViewTime":null,"Duration":null,"KeyFlag":null,"IsRecurring":null,"SelectedTech":null
    ,"Frequency":null,"DayWeekMonth":null,"IsNonBusinessDaysIncluded":null,"UntilDate":null,"ScheduleType"
    :null,"sch_cmcode":0,"sch_sitename":null,"sch_jaddr":null,"sch_suburb":null,"sch_contact":null,"sch_phone1"
    :null,"sch_instructions":null,"sch_siteno":0,"sch_sitecode":0,"sch_jobno":0,"sch_lineno":0,"sch_schno"
    :0,"JobStatus":null,"JobStatusColour":null,"IsScheduled":false,"IsQuote":false},{"Color":null,"Description"
    :null,"End":"\/Date(1459380575560)\/","EndTimezone":null,"IsAllDay":false,"RecurrenceException":null
    ,"RecurrenceRule":null,"Start":"\/Date(1459380575560)\/","StartViewDate":null,"StartViewTime":null,"StartTimezone"
    :null,"TechName":null,"emm_code":null,"Title":"demo res","ReservationID":null,"ReservedBy":null,"ReservationDate"
    :"\/Date(-62135596800000)\/","ReservationViewDate":null,"ReservationTime":null,"ReservationViewTime"
    :null,"Duration":null,"KeyFlag":null,"IsRecurring":null,"SelectedTech":null,"Frequency":null,"DayWeekMonth"
    :null,"IsNonBusinessDaysIncluded":null,"UntilDate":null,"ScheduleType":null,"sch_cmcode":0,"sch_sitename"
    :null,"sch_jaddr":null,"sch_suburb":null,"sch_contact":null,"sch_phone1":null,"sch_instructions":null
    ,"sch_siteno":0,"sch_sitecode":0,"sch_jobno":0,"sch_lineno":0,"sch_schno":0,"JobStatus":null,"JobStatusColour"
    :null,"IsScheduled":false,"IsQuote":false},{"Color":null,"Description":null,"End":"\/Date(1459380575560
    )\/","EndTimezone":null,"IsAllDay":false,"RecurrenceException":null,"RecurrenceRule":null,"Start":"\
    /Date(1459380575560)\/","StartViewDate":null,"StartViewTime":null,"StartTimezone":null,"TechName":null
    ,"emm_code":null,"Title":"demo res","ReservationID":null,"ReservedBy":null,"ReservationDate":"\/Date
    (-62135596800000)\/","ReservationViewDate":null,"ReservationTime":null,"ReservationViewTime":null,"Duration"
    :null,"KeyFlag":null,"IsRecurring":null,"SelectedTech":null,"Frequency":null,"DayWeekMonth":null,"IsNonBusinessDaysIncluded"
    :null,"UntilDate":null,"ScheduleType":null,"sch_cmcode":0,"sch_sitename":null,"sch_jaddr":null,"sch_suburb"
    :null,"sch_contact":null,"sch_phone1":null,"sch_instructions":null,"sch_siteno":0,"sch_sitecode":0,"sch_jobno"
    :0,"sch_lineno":0,"sch_schno":0,"JobStatus":null,"JobStatusColour":null,"IsScheduled":false,"IsQuote"
    :false}]);

     

    Still data is not coming.

     

  3. Kendo UI is VS 2017 Ready
  4. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 04 Apr Link to this post

    Hi Kevork,

    From the provided information it seems that possible reason for current behavior could be the name of the callback returned from the server as when testing with the same JSON data (not JSONP) the demo is working as expected on our side:
    Could you please make sure the name of the callback in which the data is wrapped is matching the one requested by the Scheduler dataSource (required by the JSONP data type that you use)? Please check the example below:

    1) Request query string parameters:
    callback:jQuery191043234444026201446_1459758208700

    2) Response: 
    jQuery191043234444026201446_1459758208700([{
      "Color": null,
      "Description": null,
      "End": "\/Date(1459380575560)\/",
      //others....
    }])

    Regards,
    Vladimir Iliev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  5. Kevork
    Kevork avatar
    39 posts
    Member since:
    May 2015

    Posted 04 Apr in reply to Vladimir Iliev Link to this post

    Nothing is coming in your demo. I changed the start date of the first object but still nothing is coming.

    Here is the changed URL: http://dojo.telerik.com/IfEpE/2

     

    Thanks.

  6. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 07 Apr Link to this post

    Hello Kevork,

    The Scheduler widget is actually bound. The provided events, however, starts on March 30th, but the widget is configured to show April 7th. Hence you will need to navigate to the specific event date in order to see them: Check the updated widget configuration starting from March 30th:
    Let me know if I am missing something.

    Regards,
    Georgi Krustev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready