EasyUI Forum

General Category => General Discussion => Topic started by: iceh on January 03, 2014, 07:17:18 AM



Title: Tree formater
Post by: iceh on January 03, 2014, 07:17:18 AM
Hi,

i use a custom formater for a tree:

Code:
            formatter: function (node) {
                var s = node.text;

                if (!node.attributes || !node.attributes.tooltip)
                    return s;

                if (node.attributes.tooltip) {
                    s = '<span title=\'' + node.attributes.tooltip + '\' class=\""easyui-tooltip\"">' + s + '</span>';
                }

                return s;
            }

The system doesn't use the jeasy UI tooltips. Any idea how i can fix this?


Title: Re: Tree formater
Post by: stworthy on January 03, 2014, 08:19:04 AM
Please parse the tooltip components when loaded data successfully.
Code:
$('#tt').tree({
  onLoadSuccess:function(){
    $.parser.parse($(this));
  }
});


Title: Re: Tree formater
Post by: iceh on January 03, 2014, 01:47:39 PM
Thx!

I also had a Typo in my formater - now it works fine!


Title: Re: Tree formater
Post by: iceh on January 06, 2014, 07:44:16 AM
Now I have an other issue ;)

It works fine, but DnD in the tree won't
kill the tooltip.

So in some instances the tooltip doesn't vanish
when a DnD event occures during the tooltip
is active.


Title: Re: Tree formater
Post by: stworthy on January 07, 2014, 12:44:10 AM
The simplest way to solve this issue is to destroy all the tooltip when start dragging a node and then restore all the tooltip when stop dragging.
Code:
	<ul class="easyui-tree" data-options="
data:data,animate:true,dnd:true,
formatter:function(node){
return '<span title=\'' + node.text + '\' class=\'easyui-tooltip\'>' + node.text + '</span>';
},
onStartDrag:function(node){
$(this).find('.tooltip-f').tooltip('destroy');
},
onStopDrag:function(node){
$.parser.parse($(this));
},
onLoadSuccess:function(){
$.parser.parse($(this));
}"></ul>



Title: Re: Tree formater
Post by: iceh on January 07, 2014, 06:45:27 AM
Thank you!

That looks soooo cool  ;D ;D ;D ;D