问题: 1.数据源的数据格式似乎错误。它来自通用列表 虽然转换为数组不起作用。 ? (加载失败 资源:服务器响应状态为500(内部 服务器错误)) 2.在页面加载时加载事件的合适事件(当前加载) 可能会发生循环依赖错误)?
我的控制器方法
`public JsonResult GetCos(int?ajaxid) {
POPM_Trn_CostingDetail cosdet = new POPM_Trn_CostingDetail();
if (ajaxid != null)
{
List<POPM_Trn_CostingDetail> arr = (from co in db.POPM_Trn_CostingDetail
where co.CostingHeader_ID == ajaxid
select co).ToList();
;
POPM_Trn_CostingDetail[] data = arr.ToArray();
return Json(data, JsonRequestBehavior.AllowGet);
}`
我的Javascript
var
$$ = function(id) {return document.getElementById(id);},
container = $$('example1'),
exampleConsole = $$('example1console'),
autosave = $$('autosave'),
save = $$('save'),
load = $$('load'),
autosaveNotification,
hot;
hot = new Handsontable(container, {
startRows: 2,
startCols: 6,
rowHeaders: true,
colHeaders: true,
autoWrapRow: true,
manualRowMove: true,
contextMenu: true,
manualRowResize: true,
manualColumnResize: true,
afterChange: function(change, source) {
jQuery.ajax({
url: "/POPM_Costing_Header/GetCos",
data: JSON.stringify({ajaxid:@Model.CostingHeader_ID}),
type: "POST",
dataType: "json",
contentType: 'application/json charset=utf-8',
async: true,
processData: false,
cache: false,
success: function (data) {
//alert(data);
hot.loadData(data);
exampleConsole.innerHTML = 'Data loaded';
},
error: function (xhr) {
alert('error');
}
});
}
});