Font Awesome icons for Webix tree nodes

主宰稳场 提交于 2019-12-06 04:07:25

问题


Webix integrates with Font Awesome. But how can Font Awesome icons be used instead of the default folder/file icons in trees to style individual nodes?

Here's what I've tried:

http://webix.com/snippet/52251623

  • template only works at the tree level
  • $css keeps the existing folder/file icon
  • there is no icon property documented for trees, yet setting one does something... it changes the folder icon into a file one, when the node has children.

回答1:


For single tree it will be like next

webix.ui({
  view:"tree",
  type:{
    folder:function(obj){
      if (obj.$count)
        return "<span class='webix_icon fa-folder'></span>";
      return  "<span class='webix_icon fa-file'></span>";
    }
  },
  data:tree_data
})

You can check the sample here - http://webix.com/snippet/0f3d85c3

If you want to share this behavior among multiple tree controls, you can define the custom type once

webix.type(webix.ui.tree, {
  name:"awesome",
  folder:function(obj){
      if (obj.$count)
        return "<span class='webix_icon fa-folder'></span>";
      return  "<span class='webix_icon fa-file'></span>";
    }
});

and later use type:"awesome" to apply the styling

webix.ui({
  view:"tree",
  type:"awesome",
  data:tree_data
})

Example - http://webix.com/snippet/79dbe741



来源:https://stackoverflow.com/questions/27577178/font-awesome-icons-for-webix-tree-nodes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!