Making datatable work faster for a MVC page getting records returned through ViewModel.

Making datatable work faster for a MVC page getting records returned through ViewModel.

anujganujg Posts: 6Questions: 2Answers: 0

I have a Asp.Net Core MVC application and the page is getting the records via ViewModel. I'm looping through the records and have applied the datatable to the table being created. When the number of records grow then the datatables perform miserably, sometimes even the page crashes. I'm doing some custom code while looping through the records, and not using the pure Ajax or Server side processing provided by datatables. Is there a way I could speed up the data display?

Re-producing the part of the code for more clarity below:

<

table id="ManageRequestsTable" class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
<th onclick="SortOnHeader('0', this.className)">Request ID</th>
<th onclick="SortOnHeader('1', this.className)">Requester</th>
<th onclick="SortOnHeader('3', this.className)">Request Title</th>
<th onclick="SortOnHeader('5', this.className)">Request Type</th>
<th onclick="SortOnHeader('6', this.className)">Complexity</th>
<th onclick="SortOnHeader('7', this.className)">Status</th>
<th>Actions</th>
</tr>
</thead>
<tfoot>
<tr>
<th style="color:#000;background:#77caf3">Request ID</th>
<th style="color:#000;background:#77caf3">Requester</th>
<th style="color:#000;background:#77caf3">Request Title</th>
<th style="color:#000;background:#77caf3">Request Type</th>
<th style="color:#000;background:#77caf3">Complexity</th>
<th style="color:#000;background:#77caf3">Status</th>
<th style="color:#000;background:#77caf3">Actions</th>
</tr>
</tfoot>
<tbody>
@for (var i = 0; i < Model.Requests.Count(); i++)
// binding the data coming through the model to the rows here

Answers

  • colincolin Posts: 15,179Questions: 1Answers: 2,590

    Hi @anujg ,

    How many records do you need before "datatables perform miserably"? There are things you can try, as listed in the FAQ.

    Cheers,

    Colin

This discussion has been closed.