Hi
i’m using dhtmlxscheduler it save to database correct but i can’t redraw it to the scheduler
Server Code
var list =
(from w in db.T_Working_Hours
where w.Clinic_ID == clinicID
select new
{
id = w.id,
start_date = w.Start_Date.Value,
end_date = w.End_Date.Value,
text = w.Note});
var retList = new List<RetWorkHours>();
foreach (var item in list)
{
var retH = new RetWorkHours();
retH.end_date = item.end_date.ToString("yyyy-MM-dd HH:mm");
retH.id = item.id;
retH.start_date=item.start_date.ToString("yyyy-MM-dd HH:mm");
retH.text = item.text;
retList.Add(retH);
}
return Json(retList, JsonRequestBehavior.AllowGet);
// return Json(await t_Working_Hours.ToListAsync(), JsonRequestBehavior.AllowGet);
}
thist is the list
JS Code
$(document).ready(function () {
scheduler.config.start_on_monday = false;
scheduler.config.full_day = true;
//scheduler.config.prevent_cache = true;
scheduler.config.xml_date = "%Y-%m-%d %H:%i";
scheduler.locale.labels.section_location = "Location";
scheduler.config.details_on_create = true;
scheduler.config.details_on_dblclick = true;
scheduler.config.prevent_cache = true;
scheduler.config.lightbox.sections = [
{ name: "description", height: 50, map_to: "text", type: "textarea", focus: true },
{ name: "time", height: 72, type: "time", map_to: "auto" }
];
scheduler.init('scheduler_here', new Date(2017, 11, 18), "week");
clinicID = $('#id').val();
$.ajax({
url: '@Url.Action("index", "T_Working_Hours")',
data: "clinicID=" + clinicID,
success: function (result) {
var d = JSON.stringify(result);
scheduler.parse(result, "json");
}
});
this var d after json
[{"id":1,"start_date":"2017-12-18 01:30","end_date":"2017-12-18 02:55","text":"New event"},{"id":2,"start_date":"2017-12-18 01:55","end_date":"2017-12-18 02:00","text":"New event"},{"id":3,"start_date":"2017-12-19 01:45","end_date":"2017-12-19 01:50","text":"New event"},{"id":4,"start_date":"2017-12-17 02:30","end_date":"2017-12-17 02:35","text":"New event"},{"id":5,"start_date":"2017-12-18 01:15","end_date":"2017-12-18 01:20","text":"New event"},{"id":6,"start_date":"2017-12-18 01:45","end_date":"2017-12-18 01:50","text":"New event"},{"id":7,"start_date":"2017-12-19 01:15","end_date":"2017-12-19 01:20","text":"New event"},{"id":8,"start_date":"2017-12-19 02:50","end_date":"2017-12-19 02:55","text":"New event"},{"id":9,"start_date":"2017-12-19 02:30","end_date":"2017-12-19 03:50","text":"New event"},{"id":10,"start_date":"2017-12-17 00:00","end_date":"2017-12-17 00:05","text":"New event"}]
What i’m doing wrong
Thanks for help