locked
Page displayin 1st set of records but doesnt loop RRS feed

  • Question

  • User-544325736 posted

    Hello everyone,

    I currently have an ASP.Net MVC C# project that gets records from a SQL Server db and displays them in a view. I have everything setup correctly but I currently have it so it only displays 12 rows per page so the users can see all the records clearly. After a min its suppose to display the next set of 12 records. I didn’t write this part of the project but I’m wondering why the next portion isn’t getting displayed. Here is the JavaScript that I Believe is suppose to be doing this?

    Thank you,

    window.onload = function () {
    
            var page = 1;
            var display = document.getElementById("rows");
            var pageRefresh = 0, slideShow = 0, notify = 0, red = 0, yellow = 0;
    
            var settings = document.getElementById("settings");
            pageRefresh = Number(settings.children[0].innerHTML) * 1000;
            slideShow = Number(settings.children[1].innerHTML) * 1000;
            notify = Number(settings.children[2].innerHTML);
            red = Number(settings.children[3].innerHTML);
            yellow = Number(settings.children[4].innerHTML);
            //console.log(pageRefresh + " " + slideShow + " " + notify + " " + red + " " + yellow);
            setTimeout("location.reload(true)", pageRefresh)
            showPage();
    
            function showPage() {
    
                if (((page - 1) * 12) > display.children.length) {
                    page = 1;
                }
    
                for (var i = 0; i < display.children.length; ++i) {
                    display.children[i].style.display = "none";
                }
    
                for (var i = ((page - 1) * 12); i < (page * 12); ++i) {
                    if (i >= display.children.length) {
                        break;
                    }
                    var current = display.children[i];
                    current.style.display = "block";
    
                    if ((i % 2) == 0) {
                        current.style.backgroundColor = "rgba(0, 0, 0, 0.2)";
                    }
                    var j = 0;
                    //console.log("The current customer is: " + current.children[0].children[0].innerHTML)
                    j = Number(current.children[1].children[0].innerHTML); // PO
                    //console.log("PO Number: " + j);
                    if (j < notify) {
                        current.children[0].children[2].style.backgroundColor = "rgba(0, 0, 255, 0.2)";
                    }
    
                    j = Number(current.children[1].children[1].innerHTML); // Invoiced
                    //console.log("Invoiced Number: " + j + "THIS IS A TESTER");
                    if (j < notify) {
                        current.children[0].children[3].style.backgroundColor = "rgba(0, 0, 255, 0.2)";
                    }
    
                    j = Number(current.children[1].children[2].innerHTML); // Received Money
                    //console.log("Received Money Number: " + j);
                    if (j < notify) {
                        current.children[0].children[4].style.backgroundColor = "rgba(0, 0, 255, 0.2)";
                    }
    
                    j = Number(current.children[1].children[3].innerHTML); // DataSheet
                    //console.log("DataSheet Number: " + j);
                    if (j < notify) {
                        current.children[0].children[5].style.backgroundColor = "rgba(0, 0, 255, 0.2)";
                    }
    
                    j = Number(current.children[1].children[4].innerHTML); // Credit Approval
                    //console.log("Credit Approval Number: " + j);
                    if (j < notify) {
                        current.children[0].children[6].style.backgroundColor = "rgba(0, 0, 255, 0.2)";
                    }
    
                    j = Number(current.children[1].children[5].innerHTML); // id Requested
                    //console.log("id Requested Number: " + j);
                    if (j < notify) {
                        current.children[0].children[7].style.backgroundColor = "rgba(0, 0, 255, 0.2)";
                    }
    
                    j = Number(current.children[1].children[6].innerHTML); // id Received
                    //console.log("id Received Number: " + j);
                    if (j < notify) {
                        current.children[0].children[8].style.backgroundColor = "rgba(0, 0, 255, 0.2)";
                    }
    
                    j = Number(current.children[1].children[7].innerHTML); // OEM
                    //console.log("OEM Number: " + j);
                    if (j < notify) {
                        current.children[0].children[9].style.backgroundColor = "rgba(0, 0, 255, 0.2)";
                    }
    
                    j = Number(current.children[0].children[10].innerHTML); // Total Days
                    //console.log("Total Days Number: " + j);
                    if (j < yellow) {
                        current.children[0].children[10].style.backgroundColor = "rgba(0, 255, 0, 0.2)";
                    } else if (j < red) {
                        current.children[0].children[10].style.backgroundColor = "rgba(255, 255, 0, 0.2)";
                    } else {
                        current.children[0].children[10].style.backgroundColor = "rgba(255, 0, 0, 0.2)";
                    }
    
                    j = Number(current.children[0].children[11].innerHTML); // Total Days Final
                    //console.log("Total Days Final Number: " + j);
                    if (j < yellow) {
                        current.children[0].children[11].style.backgroundColor = "rgba(0, 255, 0, 0.2)";
                    } else if (j < red) {
                        current.children[0].children[11].style.backgroundColor = "rgba(255, 255, 0, 0.2)";
                    } else {
                        current.children[0].children[11].style.backgroundColor = "rgba(255, 0, 0, 0.2)";
                    }
                }
                page = page + 1;
                setTimeout(showPage, slideShow);
                //setTimeout(showPage, 30000);
            }
        }
    

    Wednesday, August 21, 2019 3:56 PM

All replies

  • User-474980206 posted

    the javascript is expecting that all the records are displayed in the view. it just hides and shows segments if the page. just do a view source to see if all records are included.

    Wednesday, August 21, 2019 4:33 PM
  • User665608656 posted

    Hi ExceedingLife,

    According to your code, I found that you have reload you page in the method of setTimeout as follow:

    setTimeout("location.reload(true)", pageRefresh)

    This means after pageRefresh seconds, you refresh the page, causing all your data to be restored to the original state of the page.

    I hope you can provide more code about your html, which will help us sovle your issue more easily.

    Best Regards,

    YongQing.

    Thursday, August 22, 2019 6:48 AM