dijit/Tree 部件美化

说到美化,无非就是图标、样式等等方面的内容,下面就将就如何替换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.运行效果如下:

相关文章

我有一个网格,可以根据更大的树结构编辑小块数据.为了更容易...
我即将开始开发一款教育性的视频游戏.我已经决定以一种我可以...
我正在使用带有Grails2.3.9的Dojo1.9.DojoNumberTextBox小部...
1.引言鉴于个人需求的转变,本系列将记录自学arcgisapiforja...
我正在阅读使用dojo’sdeclare进行类创建的语法.描述令人困惑...
我的团队由更多的java人员和JavaScript经验丰富组成.我知道这...