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

Scheduler data source to scheduler bind error

1 Answer 221 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
santhosh
Top achievements
Rank 1
santhosh asked on 20 Sep 2013, 12:20 PM
Dear all,
             i'm new to kendo ui and i'd tried the samples of scheduler 
with the scheduler datasource along with AJAX and WCF
the sample source below 
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="sheduler.aspx.cs" Inherits="WebApplication1.sheduler" %>
 
<!DOCTYPE html>
 
<head runat="server">
    <title></title>
     <link href="../../App_Global/styles/kendo.common.min.css" rel="stylesheet" />
    <link href="../../App_Global/styles/kendo.default.min.css" rel="stylesheet" />
    <script src="../../App_Global/js/jquery.min.js"></script>
    <script src="../../App_Global/js/kendo.all.min.js"></script>
    <script src="App_Global/js/kendo.web.min.js"></script>   
</head>
<body>
    <div></div>
    <div id="example" class="k-content">
    
    <div id="scheduler"></div>
</div>
<script>
    var url = 'Service1.svc/';
    var dataal;
    
    var dataSource1 = new kendo.data.SchedulerDataSource({
        batch: true,
        data:dataal,
        transport: {
            read: function (options) {
                $.ajax({
                    url: url + "getsheduler",
                    dataType: "json",
                   async: false,
                    cache:false,
                    success: function (result) {
                        
                        options.success(JSON.parse(result.d));                    
                     
                    },
                    error: function (result) {
                        alert("error");
 
                    }
                });
            }          
        },
        schema: {
            model: {
                id: "taskId",
                fields: {
                    taskId: { from: "taskid", type: "number" },
                    title: { from: "taskname", defaultValue: "No title", validation: { required: true } },
                    start: { type: "date", from: "credate" },
                    end: { type: "date", from: "duedate" },
                    startTimezone: { from: "StartTimezone" },
                    endTimezone: { from: "EndTimezone" },
                    description: { from: "Description" },
                    recurrenceId: { from: "RecurrenceID" },
                    recurrenceRule: { from: "RecurrenceRule" },
                    recurrenceException: { from: "RecurrenceException" },
                    ownerId: { from: "projectid", defaultValue: 1 },
                    isAllDay: { type: "boolean", from: "IsAllDay" }
                }
            }
        }
    });

    $(document).ready(function () {
        $("#scheduler").kendoScheduler({
            date: new Date("2013/9/13"),
            startTime: new Date("2013/9/13 07:00 AM"),
            selectable: true,
            height: 600,
            views: [
            "day",
                 "week",
               { type: "month", selected: true },
 
            ],
            timezone: "Etc/UTC",
            dataSource: dataSource1
                     
        });
       });
</script>
 
</body>
</html>
and WCF source below as

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using Newtonsoft.Json;
using System.Data.SqlClient;
using System.Data;
namespace WebApplication1
{
    [ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class Service1
    {
        
 
        String strConnString = "database=sample; server=URCI74;uid=sa;password=local";
        [OperationContract]
        public void DoWork()
        {
            // Add your operation implementation here
            return;
        }
 
        // Add more operations here and mark them with [OperationContract]
 
 
        [OperationContract]
        [WebGet]
        public object getsheduler()
        {
            SqlConnection con = new SqlConnection(strConnString);          
            SqlDataAdapter adpt = new SqlDataAdapter();
            DataSet ds = new DataSet();
            adpt = new SqlDataAdapter("select projectid as ownerId, taskname as title ,credate as start,duedate [end],startTimezone,endTimezone,description,recurrenceId,recurrenceRule,recurrenceException,isAllDay from sheduler
"
, con);
            adpt.Fill(ds);
            return JsonConvert.SerializeObject(ds.Tables[0]);
         
        }
    }
}

but it the data did not bind to the scheduler calendar and if i'm giving the data source without schema it works fine  

and my output from wcf service below in attached image


please solve the above issue

thanks & regards
-santhosh

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 23 Sep 2013, 02:16 PM
Hi santhosh,

Looking at the code snippet you have pasted, it seems that the issue is caused by incorrect configuration of the schema mappings. The fields such as start, end etc. in the schema definition are mapped (via the from options) to a non existing fields in the server response. Therefore, they are not populated and no events are shown in the widget. Looking at the server response it appears that no additional mappings are required as the field names already  matches the Event required naming and you should remove the from option of the field definition.

Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Scheduler
Asked by
santhosh
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or