Hello Everyone,Not getting Id value of table td when i go to second page of datatable.

Hello Everyone,Not getting Id value of table td when i go to second page of datatable.

Jayant BelekarJayant Belekar Posts: 4Questions: 1Answers: 1
edited May 2018 in Free community support

However when i go to third page then i get the second page value.
----Html----
<td class="remain" id=@oList[iCNT].Nextupdate.Value.ToString("MM-dd-yyyy-HH-mm-ss")>
<span class="nextpage" id="next"></span>

</td>

-----Jquery call------

 $('#dataTable')
               .on('page.dt', function () {
                   $('#dataTable tr td[id]').each(function () {
                       var currVal = $(this);
                       var originalDate = currVal.attr("id").split('-');
                       var newDate = originalDate[0] + '/' + originalDate[1] + '/' + originalDate[2];
                       var finalDate = new Date(originalDate[0] + '/' + originalDate[1] + '/' + originalDate[2] + " " + originalDate[3] + ":" + originalDate[4] + ":" + originalDate[5]);
                       console.log("Second" + finalDate);
                       var second = 1000;
                       var minute = second * 60;
                       var hour = minute * 60;
                       var day = hour * 24;
                       var timer;

                       timer = setInterval(function () {
                           var now = new Date();
                           var difference = finalDate - now;
                           if (difference < 0) {
                               clearInterval(timer);
                               $('#next', currVal).html('Please Update');
                               return;
                           }
                           var days = Math.floor(difference / day);
                           var hours = Math.floor((difference % day) / hour);
                           var minutes = Math.floor((difference % hour) / minute);
                           var seconds = Math.floor((difference % minute) / second);
                           $('#next', currVal).html(hours + '' + 'hrs' + minutes + '' + 'mins' + seconds + '' + 'secs' + "  remaining!");
                       }, 1000);

                   });
               }).DataTable();

This is countdown timer application whenever i get value in td the countdowntimer should be set.But when i go to second page of datatable i am not getting values.But if switch to third page then i get the second page values.

Thanks,In Advance

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin

    Can you link to a page showing the issue please?

    Allan

  • Jayant BelekarJayant Belekar Posts: 4Questions: 1Answers: 1
    Answer ✓

    @allan Thanks for the reply.I solved the issue.I just used "createdRow" so that all values are initialize first in datatable and then called the timer function so that it will get the values no matter if we change the page.
    $('#dataTable').dataTable({
    "createdRow": function (row, data, dataIndex) {
    timer();
    }
    });
    Like this.

  • Jayant BelekarJayant Belekar Posts: 4Questions: 1Answers: 1

    Hi
    @allan Is there any event that gets fired when data in datatable changes.
    If so please let me know.

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin

    draw triggers on every draw.

    Allan

  • Jayant BelekarJayant Belekar Posts: 4Questions: 1Answers: 1

    @Allan Thanks.

This discussion has been closed.