dijit/Tree 部件美化

来源:互联网 发布:网络大电影转化率 编辑:程序博客网 时间:2024/04/28 22:53

说到美化,无非就是图标、样式等等方面的内容,下面就将就如何替换dijit/Tree部件中的图标:

1.准备样式:

.organ_icon {background: url("../images/widgets/orang.jpg") no-repeat; padding-left:16px; }  /*padding-left属性必须设置,否则不显示图标*/
.user_icon {background: url("../images/widgets/user.jpg") no-repeat; padding-left:16px; }  

2.创建dijit/Tree部件时,重构getIconClass方法,示例代码如下:

 var tree = new Tree({
                model: treeModel,
                showRoot:this.showRoot,
                getIconClass : function(item){
                    if (!item.root) {
                        var type = this.model.store.getValue(item, "type");
                        var iconClass=type.replace(/ /g, "") + "_icon";
                        return iconClass;
                    }
                    return "Others_icon";
                }
            },treeDiv);

3.运行效果如下:




0 0
原创粉丝点击