繁体   English   中英

如何在javascript中减少设置值到farpoint的加载时间

[英]How to reduce the loading time to setvalue to the farpoint in javascript

我有一个问题,通过javascript在远点设置vaule有很多加载时间来设置远点的值

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");
                }

        }
    }

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

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");
                }
        }
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM