Embedding a timer per row
Embedding a timer per row
_rain_
Posts: 4Questions: 0Answers: 0
Hi All,
Say, I want to have each row in the datatable its own personal timer. Any ideas on how to implement this?
Tried using this approach, but the value returned under the target column is undefined.
[code]
var oTable = $('#example').dataTable({
"bStateSave": true,
"bJQueryUI": false,
"bProcessing": true,
"sPaginationType": "full_numbers",
/*"sAjaxSource": '../server.side/Query.ashx',*/ // this is just an alternative source
"sAjaxSource": '../data3.txt',
"iDisplayLength": 30,
"bPaginate": true,
"aoColumnDefs": [
{
"fnRender": function (col) {
return col.aData["col1"];
}, "bUseRendered": false, "aTargets": [0], "bSortable": false, "mDataProp": null
},
{
"fnRender": function (col) {
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var seconds = currentTime.getSeconds();
if (minutes < 10) {
minutes = "0" + minutes;
}
setInterval(function () {
if (seconds != 0) {
return seconds;
}
}, 1000);
}, "bUseRendered": false, "aTargets": [1], "bSortable": false, "mDataProp": null
}
]
});
[/code]
Your assistance would be highly appreciated!
Say, I want to have each row in the datatable its own personal timer. Any ideas on how to implement this?
Tried using this approach, but the value returned under the target column is undefined.
[code]
var oTable = $('#example').dataTable({
"bStateSave": true,
"bJQueryUI": false,
"bProcessing": true,
"sPaginationType": "full_numbers",
/*"sAjaxSource": '../server.side/Query.ashx',*/ // this is just an alternative source
"sAjaxSource": '../data3.txt',
"iDisplayLength": 30,
"bPaginate": true,
"aoColumnDefs": [
{
"fnRender": function (col) {
return col.aData["col1"];
}, "bUseRendered": false, "aTargets": [0], "bSortable": false, "mDataProp": null
},
{
"fnRender": function (col) {
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var seconds = currentTime.getSeconds();
if (minutes < 10) {
minutes = "0" + minutes;
}
setInterval(function () {
if (seconds != 0) {
return seconds;
}
}, 1000);
}, "bUseRendered": false, "aTargets": [1], "bSortable": false, "mDataProp": null
}
]
});
[/code]
Your assistance would be highly appreciated!
This discussion has been closed.
Replies
fnRender will run only once for the lifetime of each row (unless you update the date with fnUpdate of course :-) ).
Allan
Thanks for the input, I appreciate it. (.^_^.)