I am using a jQuery.ajax routine to load in the database data. Here is the routine.
Handsontable.dom.addEvent(load, ‘click’, function () {
jQuery.ajax({
url: ‘/Home/getACLog’, //Controller to Get the
//JsonResult From – Json(jsonData, JsonRequestBehavior.AllowGet);
type: “GET”,
dataType: “json”,
contentType: ‘application/json; charset=utf-8’, // dataType and contentType should be json
async: true,
processData: false,
cache: false,
success: function (data) { // on Success send the Json data
// to the table by using loaddata function""
//alert(data);
//var rdata = JSON.parse(JSON.stringify(data));
//var rrdata = JSON.parse(JSON.stringify(data));
hot.loadData(data);
exampleConsole.innerHTML = ‘Data loaded’;
},
error: function (xhr) {
alert(‘error’);
}
});
Here is the controller file that it is accessing. Debug shows that the routine gets all the database data correctly. The problem is Handsometable doesn’t see the data. In stead I get an error.
public JsonResult getACLog()
{
var log = new List<ACLog>();
String[] array = new String[10];
OdbcCommand command = new OdbcCommand("SELECT fldPrimaryKey, fldCall, fldDateStr, fldTimeOnStr, fldMode, fldState, fldRstR, fldRstS, fldBand FROM tblContacts;");
using (OdbcConnection connection = new OdbcConnection("Driver={Driver do Microsoft Access (*.mdb)};dbq=C:\\Users\\User\\MasterLog.mdb;defaultdir=C:\\Users\\User;driverid=25;fil=MS Access;filedsn=C:\\Users\\User\\MasterLog.mdb.dsn;maxbuffersize=2048;maxscanrows=8;pagetimeout=5;safetransactions=0;threads=3;uid=admin;usercommitsync=Yes"))
{
command.Connection = connection;
connection.Open();
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
var logger = new ACLog();
logger.box = "false";
logger.fldPrimaryKey = (reader.SafeGetInt(0).ToString());
logger.fldCall = reader.SafeGetString(1);
logger.fldDateStr = reader.SafeGetString(2);
logger.fldTimeOnStr = reader.SafeGetString(3);
logger.fldBand = reader.SafeGetString(4);
logger.fldMode = reader.SafeGetString(5);
logger.fldState = reader.SafeGetString(6);
logger.fldRstR = reader.SafeGetString(7);
logger.fldRstS = reader.SafeGetString(8);
log.Add(logger);
}
};
}
return Json(log, JsonRequestBehavior.AllowGet);
}