I want to send the model from this View to the additionalData() function so that I can send it to a method in a controller.
@model IEnumerable<ModelLayer.Models.TableNotificationModel>
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Kendo.Mvc
@using Kendo.Mvc.UI
@{
ViewData["Title"] = "Index";
}
<script>
window.rootUrl = '@Url.Content("~/")';
</script>
<h1>Upload index</h1>
<div>
<h4>Upload file</h4>
<form asp-controller="Upload" asp-action="Upload"
enctype="multipart/form-data" method="post">
<input type="file" name="file" />
<button type="submit" id="uploadBtn">Upload</button>
</form>
@if (ViewBag.Message != null)
{
<script>
$(document).ready(function(){
alert('@Html.Raw(ViewBag.Message)');
});
</script>
}
</div>
<div class="clearfix">
@(Html.Kendo().Grid<ModelLayer.Models.TableNotificationModel>()
.Name("notificationGrid")
.Pageable(pageable => pageable.Input(true).Numeric(false))
.Scrollable()
.Sortable()
.Filterable()
.ColumnMenu()
.Columns(columns =>
{
columns.Bound(c => c.OPERATOR_OBJECTID).Title("ID").Hidden();
columns.Bound(c => c.SETTLEMENT_CODE).Title("settlement code").Width("100px");
columns.Bound(c => c.TECHNOLOGY_CODE).Title("tech code").Width("100px");
columns.Bound(c => c.UPLOAD_SPEED_CLASS_CODE).Title("upload").Width("100px");
columns.Bound(c => c.DOWNLOAD_SPEED_CLASS_CODE).Title("download").Width("100px");
columns.Bound(c => c.DATA_CATEGORY_QOS_CODE).Title("data category").Width("100px");
columns.Bound(c => c.SHAPE).Title("shape").Width("100px");
columns.Bound(c => c.Message).Title("message").Width("100px");
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Upload_Read", "Upload").Data("additionalData"))
)
)
</div>
<script>
function additionalData() {
return {
operatorId: "@Model.operator"
}
}
</script>
but I see that it's now correct this way, it's not working. How can I access the Model from the JS function?