flexlib dataGrid out of bounds 解决方法

修改源文件中的getItemDepth方法,做如下改动:

protected function getItemDepth(item:Object, offset:int):int
    {
      var depth:int;
      //if the dataprovider have a root, we begin from the root.
      if (hasRoot)
      {
    depth = searchForCurrentDepth(_rootModel[0], item);
      }
      //If the dataprovider don't have a root, we need to parse all items from the first level.
      else
      {
        var i:int = 0;
        do
        {
   if (i == _rootModel.length) break;
          depth = searchForCurrentDepth(_rootModel[i++], item);
        } while (depth == -1)
      }
      if (depth == -1)
    trace("item not found");
        //throw new Error("item not found");
      return depth;
    }

主要是修改了红色标注的代码,绿色标识的部分可改可不改。不影响最终的结果
if (i == _rootModel.length) break;
修改这部分代码的原因是   第一层循环的次数最多不超过根节点的个数,如果超出,则跳出循环

trace("item not found");
不再抛出错误,而是打印错误语句,,,主要是查找item==null的节点深度时

这样修改代码后,TreeGrid的数据源重新赋值也不会出现错误了。


如何编译源代码,参考上一篇文章~~~

参考自:http://bbs.airia.cn/thread-43581-1-1.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值