I am trying to get data from my database and display it in handsontable using Json. Here is the code I have written so far. Can anyone guide me about how tosolve this problem.
[HttpGet]
public JsonResult Index()
{
IEnumerable<SupplierTypeDto> supplierType = new List<SupplierTypeDto>();
var apiResponse = Post<List<SupplierTypeDto>>("api/SupplierType/SuppliersType", null);
if (apiResponse != null)
{
if (apiResponse.Success)
{
supplierType = apiResponse.Data;
// ShowSuccessMesage(string.Format(ResponseMessages.DATA_Load_Success, "Customers"));
}
}
else
{
ShowErrorMesage(ResponseMessages.API_NoResponse);
}
return Json(supplierType,JsonRequestBehavior.AllowGet);
}
The code added below has data part and I want that data from Json so I can show it in Index file.
<script>
const data = [
['', 'Tesla', 'Volvo', 'Toyota', 'Ford'],
['2019', 10, 11, 12, 13],
['2020', 20, 11, 14, 13],
['2021', 30, 15, 12, 13]
];
const container = document.getElementById('example');
const hot = new Handsontable(container, {
data: data,
rowHeaders: true,
licenseKey: 'non-commercial-and-evaluation',
colHeaders: true
});
</script>
You have line
const container = document.getElementById('example');
but non html was provided in example. So probably you just need to add
<div id="example"></div>
to your html code
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.