We are trying the trial version to determine if we are going to purchase it but my testing has run into a problem. I am trying to load a data source in JavaScript so that will be called when a id from the treeview is passed on selection ( that part is working) , but when I call my java script function the data source creates but no data is returned, I have included my JavaScript function here and I have also included the method from the controller it is to call, can someone tell me why I get no data back, i have created an alert at the end of the function to show the data but the length is always zero for the loop does not execute
here is the JavaScript
var updateAgencySystemInfo = function (agencyId, agencySystemModel) {
var ds = new kendo.data.DataSource({
trasnport: {
read: {
type:"POST",
url: "/Administrator/GetAgencySystemInfo",
contentType: "application/json; charset=utf-8",
dataType: "json"
},
parameterMap: function (options, operation) {
switch (operation) {
case "read":
return JSON.stringify(options);
break;
//case "destroy":
// return JSON.stringify(options);
// break;
//case "create":
//case "update":
// return JSON.stringify(options);
// break;
}
}
},
schema: {
model: {
id: "AgencySystemID", // the identifier of the model
fields: {
"AgencySystemID": { type: "number", editable: false },
"AgencyID": { type: "number", editable: false },
"Description": { type: "string" },
"DatabaseTypeID": { type: "number" },
"DataSource": { type: "string" },
"InitalCatalog": { type: "string" },
"UserID": { type: "string" },
"Password": { type: "string" },
"LastImportStartDateTime": { type: "date" },
"LastImportEndDateTime": { type: "date" },
"NextImportDateTime": { type: "date" },
"UpToDateTime": { type: "date" },
"ImportFrequency": { type: "number" },
"ImportFrequencyUnitID": { type: "number" },
"MaxImportWindow": { type: "number" },
"IsActive": { type: "boolean" }
}
}
}
});
ds.read({ Id: agencyId });
ds.fetch();
var datasourcedata = ds.data();
for (var i = 0; i < datasourcedata.length; i++) {
var dataitem = datasourcedata[i].Description;
alert(dataitem);
}
return datasourcedata.length;
};
Now here is the method from the controller the datasource is to call for the data.
[HttpPost]
public JsonResult GetAgencySystemInfo(long? agencyID)
{
var agencySystemInfo = (from p in dc.mst_AgencySystem where p.AgencyID == agencyID select p).ToList();
return Json(agencySystemInfo, JsonRequestBehavior.AllowGet);
}
Thanks,
rglunt68
here is the JavaScript
var updateAgencySystemInfo = function (agencyId, agencySystemModel) {
var ds = new kendo.data.DataSource({
trasnport: {
read: {
type:"POST",
url: "/Administrator/GetAgencySystemInfo",
contentType: "application/json; charset=utf-8",
dataType: "json"
},
parameterMap: function (options, operation) {
switch (operation) {
case "read":
return JSON.stringify(options);
break;
//case "destroy":
// return JSON.stringify(options);
// break;
//case "create":
//case "update":
// return JSON.stringify(options);
// break;
}
}
},
schema: {
model: {
id: "AgencySystemID", // the identifier of the model
fields: {
"AgencySystemID": { type: "number", editable: false },
"AgencyID": { type: "number", editable: false },
"Description": { type: "string" },
"DatabaseTypeID": { type: "number" },
"DataSource": { type: "string" },
"InitalCatalog": { type: "string" },
"UserID": { type: "string" },
"Password": { type: "string" },
"LastImportStartDateTime": { type: "date" },
"LastImportEndDateTime": { type: "date" },
"NextImportDateTime": { type: "date" },
"UpToDateTime": { type: "date" },
"ImportFrequency": { type: "number" },
"ImportFrequencyUnitID": { type: "number" },
"MaxImportWindow": { type: "number" },
"IsActive": { type: "boolean" }
}
}
}
});
ds.read({ Id: agencyId });
ds.fetch();
var datasourcedata = ds.data();
for (var i = 0; i < datasourcedata.length; i++) {
var dataitem = datasourcedata[i].Description;
alert(dataitem);
}
return datasourcedata.length;
};
Now here is the method from the controller the datasource is to call for the data.
[HttpPost]
public JsonResult GetAgencySystemInfo(long? agencyID)
{
var agencySystemInfo = (from p in dc.mst_AgencySystem where p.AgencyID == agencyID select p).ToList();
return Json(agencySystemInfo, JsonRequestBehavior.AllowGet);
}
Thanks,
rglunt68