Deferrender not working
Deferrender not working
Below is how I initialize the table. The table renders correctly with a hyperlink to the document but it loads a bit slow. I have around 4000 records and it takes around 3 secs. I want to add other columns to the table which I need to customize by render function as the below one. When I do that the render time increases to about 10 secsn which is not acceptable
I have a listener on rowCreated but it does not log anything. What am I doing wrong?
$('#listDocuments').DataTable({
"ajax" : {
'url' :'/WAS/admin/getDocumentsList',
'type' : 'GET',
'dataSrc':''
},
"destroy" : true,
"deferRender": true,
"autoWidth" : false,
"columns": [
{
'data': 'documentName',
'defaultContent': 'documentName',
'render': function (data, type, row, meta) {
return generateHyperLink(row.documentName, row.documentLink);
}
}]
});
This question has an accepted answers - jump to answer
Answers
I'm not sure about this. Maybe you can show the code or a test case:
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
The render function will have multiple passes for different "types". Please see the following docs for more info:
Orthogonal Data
columns.render
I think you will just want to render the
generateHyperLink
for thedisplay
type. This way that function is only called when the row is displayed. The "Show ellipsis..." example in thecolumns.render
doc shows an example of this.Kevin
I added
"createdRow": function ( row, data, index ) {
console.log("createdRow called");
},
and it is called 10 times the first page is rendered as it expected.
But still the page takes a lot of time to load. I have timed my server call and returns in about 2 secs. If I add render for just one column, it takes about 3 secs. As I add more columns and their render functions the table load time increases to about 10-14 secs.
I have 7 columns in this table.
My suggestion was to do something like this:
With deferRender this should decrease the table load time.
As a test you can see how long the table takes to load without
columns.render
to compare when you add the renders.Kevin
Thank you so much. That works