Datatable performance improvement
Datatable performance improvement
I am using datatbale with MVC.Net.
I have a data table with 26 columns and around 3000 rows which is experiencing performance issues. It takes around one minute for DataTables to render the table (Data is returning from controller very quickly but converting in to Datatable is taking so long). Due to business requirements I cannot use paging and searching, so DataTables is having to render all 3000 records. My .cshtml file will create HTML DOM table and then my data table is:
var table = $('#tblReport').DataTable({
"paging": false,
"info": false,
fixedHeader: true,
searching: false,
scrollY: tableH + "px",
scrollX: true,
scrollCollapse: true,
});
new $.fn.dataTable.FixedColumns(table, {
leftColumns: 1,
heightMatch: 'auto'
});
I read that it would be faster if I used ajax instead of making DataTables convert the DOM. But due to business requirement, I could not use ajax because my rows are not straight forward(I need to color the cells based on my model, need to show popup for few cells, etc).
Could anyone please help me how can I improve the performance of this kind of datatable?
Answers
The Speed FAQ provides the options available. If you were to use Ajax then
deferRender
might help. You can use things likecolumns.render
render HTML elements for the cells andcolumns.createdCell
,createdRow
orrowCallback
can be used to apply CSS, classes, etc to the cells.Let us know if you have further questions or need help with these options.
Kevin