首页 > 解决方案 > 如何减少加载时间以在javascript中将值设置为远点

问题描述

我在通过 javascript 在 farpoint 中设置 vaule 时遇到问题 需要花费大量加载时间来设置 farpoint 中的值

if (row != 0) {

        if (ss.GetValue(row, col) != "") {
            sTrips = parseFloat(ss.GetValue(row, col));   
        }
        if (ss.GetValue(0, col) != "") {
            sWrkDays = parseFloat(ss.GetValue(0, col));      
        }
        for (var i = 1; i < ssDet.GetRowCount(); i++) {

                if (ssDet.GetValue(i, 7) != "") { 
                    sMaxCapacity = parseFloat(ssDet.GetValue(i, 7));
                    sVal = 0;
                    sVal = sMaxCapacity * sTrips * sWrkDays;
                    var cell = ssDet.GetCellByRowCol(i, col + 5); 
                    cell.removeAttribute("fpcelltype");

                    ssDet.SetValue(i, col + 5, sVal);
                    cell.setAttribute("FpCellType", "readonly");
                }

        }
    }

标签: javascriptasp.netoracle

解决方案


尝试下面的优化代码以获得更好的结果

if (row != 0) {
        var sTripsVal = ss.GetValue(row, col);
        var workingDays = ss.GetValue(0, col);

        if (sTripsVal != "") {
            sTrips = parseFloat(sTripsVal);   
        }
        if (workingDays  != "") {
            sWrkDays = parseFloat(workingDays);      
        }

        for (var i = 1; i < ssDet.GetRowCount(); i++) 
        {
                var MaxCapacity = ssDet.GetValue(i, 7);
                if (MaxCapacity != "") 
                { 
                    sMaxCapacity = parseFloat(MaxCapacity);
                    sVal = 0;
                    sVal = sMaxCapacity * sTrips * sWrkDays;
                    var cell = ssDet.GetCellByRowCol(i, col + 5); 
                    cell.removeAttribute("fpcelltype");

                    ssDet.SetValue(i, col + 5, sVal);
                    cell.setAttribute("FpCellType", "readonly");
                }
        }
    }

推荐阅读