javascript - 如何减少加载时间以在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");
}
}
}
解决方案
尝试下面的优化代码以获得更好的结果
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");
}
}
}
推荐阅读
- java - Intellij Idea 插件语法高亮和代码完成在 ${} 中的 Java 字符串中,如 Scala 字符串插值
- python - 访问由 Snakemake 中的函数返回的列表的特定元素
- django - Django CreateView:'str'对象不可调用
- python - 如何使用给定列表中的计数器查找特定键的值
- javascript - JavaScript函数在表单提交上不起作用
- php - 合并和求和多个多维关联数组 PHP
- java - 替换数组中的所有重复项
- node.js - Nuxt - 安装 Sass 时的错误墙
- java - 在 android 上保存不止一张图片和视频。可能使用 intent_action_still_image_camera
- java - 在 Spring MVC 项目中使用基于 XML 的配置时,从 @Autowired bean 获取 null