Using Datatables without ajax call

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 anni tempo fa
Hi,
there is a way to use Datatables without an ajax call?
What i would like to do is:
Use the partial page "Table" and pass an array of products
@await Html.PartialAsync("Table", new DataTablesModel
                       {
                           Name = "listview-grid",
                           Data = Model.Products
                       })

the problem I encountered is in _Table.Definition page;
@if (Model.Data != null)
{    
    <text>
        data: @Html.Raw(Model.Data.ToString()),
    </text>
}
this piece of code don't pass the array to the DataTables but render Model.Data as text.
Thanks.
4 anni tempo fa
You can transfer an array of data without using ajax. You can find an example in our source code, here is the part of the code you need:

Data = JsonConvert.SerializeObject(Model.ActivityLogTypeListModel.Select(typeModel => new
                    {
                        typeModel.Id,
                        typeModel.Name,
                        Enabled = typeModel.Enabled
                    }).ToList())
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.