Попытка передать данные, полученные с нашего сервера SQL, в шаблон E JS с некоторым встроенным Javascript. Вот несколько фрагментов моего кода, чтобы показать вам, что я пытаюсь сделать.
Файл маршрута
const data = await sqlCalls.getMenuAccess(req.user.UserIdNo)
const data2 = await sqlCalls.getAvailability();
const menus = data.recordset
const availability = data2.recordset
res.render('portal-availability',
{
title: 'Availability',
name: req.user.FirstName,
menudata: menus,
availabilitydata: availability // <--- This is the data that I want to use in my EJS template.
});
});
HTML Часть моего E JS шаблон
<section class="content">
<div class="container-fluid">
<div class="block-header">
<h2>AVAILABILITY</h2>
</div>
<div id="grid"></div>
</div>
</section>
Javascript в моем E JS шаблоне
<script>
$(document).ready(function() {
$("#grid").kendoGrid({
dataSource: {
data: availability, // <---- This is where I am trying to use availability to bind to my grid.
schema: {
model: {
fields: {
ItemIdNo: { type: "number" },
cultivardescription: { type: "string" },
containerdescription: { type: "string" },
week0: { type: "number" }
}
}
}
});
});
</script>
Любая помощь будет принята с благодарностью.
Спасибо! Джим