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

Scheduler Date Format and no Mapping Fields

4 Answers 266 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Asat
Top achievements
Rank 1
Asat asked on 19 May 2014, 05:48 AM
Hi, 

I have following code,

$("#activities").kendoScheduler({
date: new Date("2014/5/19"),
startTime: new Date("2014/5/19 00:00 AM"),
endTime: new Date("2014/5/19 08:00 PM"),
views: [
{ type: "day", selected: true },
"week",
"month"
],
editable: false,
timezone: "Etc/UTC",
dataSource: {
batch: true,
transport: {
read: {
type: 'POST',
contentType: "text/xml",
url: "https:///xxx:8443/xxx/rest/xxxapp/api/xxxGetActivities",
processData: false,
dataType: "xml",
headers: { 'X-xxx-Token': '8430694659957936307' }
},
parameterMap: function() {
return '<?xml version="1.0" encoding="UTF-8" standalone="no"?><xxxGetActivitiesRequest xmlns="http://www.xxx.net/xxx/1.0"><RecordLimit>30</RecordLimit><RequestFields><Activities><Activity><ActivityNo/><AccountName/><AccountNumber/><ContactFullName/><ContactName/><ContactNameSequence/><ActivitySubject/><ActivityPriority/><ActivityPriorityCode/><ActivityText1/><ActivityText2/><ActivityText3/><ActivityStatus/><ActivityStatusCode/><ActionDate/><ActionTime/><ActionDateTime/><EndDate/><Location/><ActivityResolution/><ActivityResolutionCode/><ActivityType/><ActivityTypeCode/><LeadOpportunityNo/><LeadOpportunityTypeCode/><LeadOpportunityDetails/></Activity></Activities></RequestFields><Filters><ActivityStatusCode><Like>%</Like><NotLike>F</NotLike><NotLike>C</NotLike></ActivityStatusCode><ActionDate><Range><From>D-30</From><To>D+30</To></Range></ActionDate></Filters></xxxGetActivitiesRequest>'
}
},
schema: {
model: {
id: "activityNo",
fields: {
activityNo: { from: "ActivityNo", type: "number" },
title: { from: "ActivitySubject", defaultValue: "No title", validation: { required: true } },
start: { type: "date", from: "ActionDate" , format: "{0:dd-MMM-yyyy}"},
end: { type: "date", from: "EndDate", format: "{0:dd-MMM-yyyy}" },
atendees: { from: "ContactFullName", nullable: true },
startTimezone: { from: "StartTimezone",nullable: true  },
endTimezone: { from: "EndTimezone",nullable: true  },
description: { from: "Description",nullable: true  },
recurrenceId: { from: "RecurrenceID",nullable: true  },
recurrenceRule: { from: "RecurrenceRule",nullable: true  },
recurrenceException: { from: "RecurrenceException",nullable: true  },
roomId: { from: "RoomID", nullable: true },
isAllDay: { type: "boolean", from: "IsAllDay" , nullable: true }
}
}
}
}
}); 


Even though I can see the call is made to the web service and correct data is downloaded, no activities are not displayed in the scheduler as I expect. Few questions,

1. In the service I don't have all the schema models. So I have put dummy from fields with nullable true. is that correct
2. Dates are passed back from the web service in dd-MMM-yyyy format (ex: 14-May-2014). How can I map it to underlying dates in Kendo (is it automatically done?). I am not talking about visual aspects here but background mapping. 
3. Is there anything else wrong in my code? 


You help is highly appreciated.
Asat


4 Answers, 1 is accepted

Sort by
0
Asat
Top achievements
Rank 1
answered on 19 May 2014, 10:59 AM
Even the following is not working ... So probably its a different issue..
 ....
title: { from: "ActivitySubject", defaultValue: "No title", validation: { required: true } },
start: new Date("2014/5/21 08:00 AM"), 
end: new Date("2014/5/21 14:00 AM"),

atendees: { from: "ContactFullName", nullable: true },
....

Anyone?
0
Vladimir Iliev
Telerik team
answered on 21 May 2014, 07:06 AM
Hi Asat,

As the server returns the dates in custom format you should manually parse them using the dataSource schema.parse function. Please check the example below:

schema: {
    parse: function(data) {
        for (var i = 0; i < data.length; i++) {
            data[i].start = new Date(data[i].start);
            data[i].end = new Date(data[i].end);
        }
        return data;
    },

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Asat
Top achievements
Rank 1
answered on 21 May 2014, 11:01 AM
Sorry Vladimir, 

I am still bit confused. I tried what you suggested but with no luck. Can you please provide me with a sample (with XML)?

My current code is as below,

schema: {
                    model: {
                        id: "activityNo",
                        fields: {
                            activityNo: { from: "ActivityNo", type: "number" },
                            title: { from: "ActivitySubject", defaultValue: "No title", validation: { required: true } },
                            start: { type: "date", from: "ActionDate" , format: "{0:dd-MMM-yyyy}"},
                            end: { type: "date", from: "EndDate", format: "{0:dd-MMM-yyyy}" },
                            atendees: { from: "ContactFullName", nullable: true },
                            startTimezone: { from: "StartTimezone",nullable: true  },
                            endTimezone: { from: "EndTimezone",nullable: true  },
                            description: { from: "Description",nullable: true  },
                            recurrenceId: { from: "RecurrenceID",nullable: true  },
                            recurrenceRule: { from: "RecurrenceRule",nullable: true  },
                            recurrenceException: { from: "RecurrenceException",nullable: true  },
                            roomId: { from: "RoomId", nullable: true  },
                            isAllDay: { type: "boolean", from: "IsAllDay" , nullable: true }                           
                        }
                    },
                    parse: function(data) {
                        for (var i = 0; i < data.length; i++) {
                            data[i].start = new Date(data[i].start);
                            data[i].end = new Date(data[i].end);
                        }              
                        return data;
                    }          
                }  


regards,
Asat
0
Vladimir Iliev
Telerik team
answered on 23 May 2014, 08:40 AM
Hi Asat,

Please find the attached demo of Scheduler bind to XML source - you can use that example as a baseline to create "parameterMap" function that is suitable for the data returned from the server. 

Kind Regards,
Vladimir Iliev
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
Asat
Top achievements
Rank 1
Answers by
Asat
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or