日期:2014-05-19  浏览次数:20472 次

用梅花雪树形控件时出现的问题,谁用过进来讲一讲
如下代码:
function   ShowTree()
{
    var   tree   =   new   MzTreeView( "tree ");

    tree.icons[ "property "]   =   "property.gif ";
    tree.icons[ "css "]   =   "collection.gif ";
    tree.icons[ "book "]     =   "book.gif ";
    tree.iconsExpand[ "book "]   =   "bookopen.gif ";  
    tree.setIconPath( "jsimg/ ");  

    tree.nodes[ "0_100 "]   =   "text:1;   data:id=100 ";
    tree.nodes[ "100_200 "]   =   "text:1;   data:id=200 ";
    tree.nodes[ "200_300 "]   =   "text:1;   data:id=300 ";

    tree.setURL( "default.htm ");
    tree.setTarget( "MzMain ");
    document.write(tree.toString());        
    }

现在我想从数据库中提取数据用递归来填充这个树,只有三级,我的思路是这样:把上面的代码改成一个有三个参数x,y,z的函数,分别替换100,200,300这三个数字,不知道对不对?不知道该怎么改?
    tree.nodes[ "0_100 "]   =   "text:1;   data:id=100 ";
    tree.nodes[ "100_200 "]   =   "text:1;   data:id=200 ";
    tree.nodes[ "200_300 "]   =   "text:1;   data:id=300 ";
上面代码中的100如果用一个变量x来代替要怎么写?
这样对吗?tree.nodes[ "0_ "x " "]   =   "text:1;   data:id=100 ";

------解决方案--------------------
帮顶