slickgrid - 从自定义格式化程序引用外部对象以及加载时间问题

时间:2012-08-10 15:26:41

标签: javascript slickgrid

我在下面创建了格式化程序,我需要检查一个与我所在单元格坐标相同的对象的属性。

例如,如果我在网格中的cell (1,2)上,为了确定格式,我必须检查是否定义了OBJECT[1][2].formula

我在下面以一种简单的方式做了这个,但我怀疑我使用了错误的技术,因为加载非常很长时间,浏览器甚至会问我是否要停止脚本。

是否有更好的方法可以从格式化程序中访问外部参数?

由于

function styleFormatter(row, cell, value, columnDef, dataContext) {

// here I access an external data structure (a graph) that is linked to the grid to store additional info
//this graph is initially empty so the nodes are undefined, so I use a try catch to handle this


         try {
        if (myGraph.getNodeByCoords(row,col)) {
            var node = myGraph.getNodeByCoords(row,col);
        }
    } catch(e) {}

    if (value == null || value === "") {

        return "";

    } else if(node.formula) {

            return "<div class='cell-has-formula'>" + value + "</div>";
    } else { 

            return "<div class='cell-has-string'>" + value + "</div>";
        }


    }

}

0 个答案:

没有答案