ASP.NET CORE Passing Model As Data

ASP.NET CORE Passing Model As Data

MarkPerryMarkPerry Posts: 1Questions: 1Answers: 0
edited May 2021 in DataTables 1.10

Is it possible to do something like this when passing data to a datatable?

the @Model.KIT_REQUEST_ITEM is a List<Object>

   $(document).ready(function () {

            var table = $('#details').DataTable({
                processing: true,
                serverSide: false,
                paging: false,
                ordering: true,
                searching: true,
                info: false,
                data: @Model.KIT_REQUEST_ITEM,               
                columns: [
                    { data: "Name" },
                    { data: "FBS_KITREQITEM_ORDEREDQUANTITY" }
                ]
            });
        });

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Not exactly like that since the Javascript engine won't run the .NET Core stuff. However, if you are able to transform your model into JSON then yes, you could use the data property to populate the table as shown here.

    Allan

This discussion has been closed.