fnDraw inefficient with drawing images

fnDraw inefficient with drawing images

mbroadstmbroadst Posts: 14Questions: 0Answers: 0
edited October 2011 in DataTables 1.8
Greetings,
I have a table that contains an images, and its on an auto-refresh timer. Currently, that means that every 5-10 seconds (whatever the timer is set to) the table is refreshed and there is a blink for reloading that image. Is there any way to avoid this?

I suppose that what this really comes down to is: is it possible to refresh table rows only when there is an actual data change, rather than blindly updating everything regardless of the data being used?

the column definitions look like this:
[code]
{"mDataProp":'index', "bVisible":false},
{"mDataProp":'icon', "sTitle":'{{=T("Icon")}}',
"bSortable": false,
"fnRender": function(obj) {
var sIconName = obj.aData['icon'];
if (sIconName) {
var iconUrl = "{{=URL('icon', 'view')}}?" + $.param({'name': sIconName})
return '';
} else {
return "";
}
}
,"bUseRendered": false
},
{"mDataProp":'name', "sTitle":'{{=T("Name")}}'},
{"mDataProp":'local_display_name', "sTitle":'{{=T("Local Display Name")}}'},
{"mDataProp":'protocol', "sTitle":'{{=T("Protocol")}}'},
{"mDataProp":'description', "sTitle":'{{=T("Description")}}'}
]
[/code]

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    There's another thread on this and I believe Allan discusses ideas for improving performance:

    [quote]So regarding your question, I think your method 2 is very close, but I would suggest a couple of things. Firstly make use of the fourth parameter for fnUpdate, which disables the table for redrawing on every call - that's really expensive and this little change should help a lot[/quote]

    http://www.datatables.net/forums/discussion/7103/help-with-performance-for-1hz-table-refreshing#Item_5
  • mbroadstmbroadst Posts: 14Questions: 0Answers: 0
    I agree that a similar solution might work, but the problem is that everything already works so well the "DataTables" way - aside from the icon redraw. What I mean here is that the ajax + pagination + sorting all work so well I don't want to lose that.

    I guess the ideal solution would be to have a version fnDraw that does what the solution in that post does, and allows for a callback each time a row is drawn in order for me to specify if the update should indeed occur (has data changed at all?). I'll try to write up some code for this.
This discussion has been closed.