I found a very strange problem, and it took my another 4 hours, can't solve it:
BackGround: the latest kendoUI. the scheduler could show it's self, with no js errors. The client-side code is below:
On the server side, it's asp.net c#. And I have an A/B test.
Test A:
In Test A, I just write a json string into an variable, then response back it to the browser. In the requestEnd: I received it correctlly. Please NOTE that I know it's not a full set of the fields, my point is not talking about that, just see the Test B.
Test B:
Please NOTE that the C# has no errors, and the server could return the json VERY WELL. I know it because I copy the "KPIGetData/DimData.aspx?SearchInput=schedulerevent/&SearchValue="+CurrentUserID+"&StartTime="+SearchTimeStart+"&EndTime"+SearchTimeEnd" in to the brower address-line and enter to see the return json. In TestA and TestB, both return [{"TaskID123":"885"}]
But in TestB, the Scheduler can't receive the json in the requestEnd: at all!
alert("here:"+response +"|"+JSON.stringify(response));
it shows: here:undefined|undefined
I test these for many times, the result is the same.
I found that the ONLY diffrent between A/B is, in TestA, the Json is in a constant, hard coded string like 885, even you hard code it into an variable, it's a constant in fact. But in TestB, the Json is created from a real variable, which get value from database.
So the conclusion is, (I know it's impossible, but don't know what's wrong), the Scheduler's Read could only get Json from a hard coded constant string, may be your demo site use the hard coded constant string Json to demo in your backend? When the Json is not hard coded in the C#, Scheduler will get an undefined or just an empty.
By the way, I have tested this:
return new JavaScriptSerializer().Serialize(Tasktings);
Taskting is a list<> which created to hold the values.
The result is same.
I swear I met this problem( a hard coded json in c#, is diffrent with one created from variable) many years ago. But I did not write down what happened and how to solve it.
Please help, the scheduler is very hard to use, document and online demo has litte full-example, only show one of the few main functions.
I have spend over 15 hours in the sheduler, I am very sorry, but please help.
yours,
Ivan
BackGround: the latest kendoUI. the scheduler could show it's self, with no js errors. The client-side code is below:
jQuery("#workcalendar").kendoScheduler({ date: new Date(), startTime: new Date("2013/6/13 07:00 AM"), height: 600, views: [ "day", { type: "workWeek", selected: true }, "week", "month", "agenda" ], //timezone: "Etc/UTC", dataSource: { transport: { read: { type: "POST", url: "KPIGetData/DimData.aspx?SearchInput=schedulerevent", dataType: "json" }, update: { type: "POST", url: "KPIGetData/DimSavingData.aspx?SearchInput=schedulereventedit", dataType: "json" }, create: { type: "POST", url: "KPIGetData/DimData.aspx?SearchInput=schedulereventadd", dataType: "json" }, destroy: { type: "POST", url: "KPIGetData/DimData.aspx?SearchInput=schedulereventdel", dataType: "json" } , parameterMap: function(options, operation) { if (operation === "read") { var result ="&SearchValue="+CurrentUserID+"&StartTime="+SearchTimeStart+"&EndTime"+SearchTimeEnd; alert("hit:"+result); return kendo.stringify(result); } else if (operation !== "read" && options.models) { return {models: kendo.stringify(options.models)}; } } } , schema: { model: { id: "taskId", fields: { taskId: { from: "TaskID",type: "number"}, title: { from: "Title",defaultValue: "No title", validation: { required: true }}, start: { type: "date", from: "Start" }, end: { type: "date", from: "End" }, description: { from: "Description" }, recurrenceId: { from: "RecurrenceID" }, recurrenceRule: { from: "RecurrenceRule" }, recurrenceException: {from:"RecurrenceException"}, ownerId: {from: "OwnerID", defaultValue: 1}, isAllDay: {type: "boolean",from:"IsAllDay"} } } }, requestEnd: function(e) { var response = e.response; alert("here:"+response +"|"+JSON.stringify(response)); }, error: function(e) { alert(e.status); } } });On the server side, it's asp.net c#. And I have an A/B test.
Test A:
string test1 = "[{\"TaskID123\":\"885\"}]"; Response.Clear(); Response.ContentType = "application/json"; Response.Charset = "UTF-8"; Response.Write(test1); Response.End();Test B:
DataTable dt = null; DataRow[] drdtv = null; using (System.Data.SqlClient.SqlConnection cn = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["HROK"].ConnectionString)) { cn.Open(); string sql = "select top 1 TableID from OAOrderTaskFactBill"; SqlCommand cmd = new SqlCommand(sql, cn); SqlClient.SqlDataAdapter ada =new SqlClient.SqlDataAdapter(); ada.SelectCommand = cmd; ada.Fill(dt);} string test2 = "[{" + "\"" + "TaskID" + "\"" + ":" + "\"" + dt.Rows[0]["TableID"].ToString() + "\"" + "}]"; Response.Clear(); Response.ContentType = "application/json";Response.Charset = "UTF-8";Response.Write(test2);Response.End();Please NOTE that the C# has no errors, and the server could return the json VERY WELL. I know it because I copy the "KPIGetData/DimData.aspx?SearchInput=schedulerevent/&SearchValue="+CurrentUserID+"&StartTime="+SearchTimeStart+"&EndTime"+SearchTimeEnd" in to the brower address-line and enter to see the return json. In TestA and TestB, both return [{"TaskID123":"885"}]
But in TestB, the Scheduler can't receive the json in the requestEnd: at all!
alert("here:"+response +"|"+JSON.stringify(response));
it shows: here:undefined|undefined
I test these for many times, the result is the same.
I found that the ONLY diffrent between A/B is, in TestA, the Json is in a constant, hard coded string like 885, even you hard code it into an variable, it's a constant in fact. But in TestB, the Json is created from a real variable, which get value from database.
So the conclusion is, (I know it's impossible, but don't know what's wrong), the Scheduler's Read could only get Json from a hard coded constant string, may be your demo site use the hard coded constant string Json to demo in your backend? When the Json is not hard coded in the C#, Scheduler will get an undefined or just an empty.
By the way, I have tested this:
return new JavaScriptSerializer().Serialize(Tasktings);
Taskting is a list<> which created to hold the values.
The result is same.
I swear I met this problem( a hard coded json in c#, is diffrent with one created from variable) many years ago. But I did not write down what happened and how to solve it.
Please help, the scheduler is very hard to use, document and online demo has litte full-example, only show one of the few main functions.
I have spend over 15 hours in the sheduler, I am very sorry, but please help.
yours,
Ivan