fnDraw inefficient with drawing images
fnDraw inefficient with drawing images
mbroadst
Posts: 14Questions: 0Answers: 0
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]
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]
This discussion has been closed.
Replies
[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
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.