EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: ShockRaver on July 25, 2014, 04:29:33 AM



Title: Tooltip on edatagrid does not disappear
Post by: ShockRaver on July 25, 2014, 04:29:33 AM
Good day,

I have used the tooltip on my editable datagrid. The tooltip itself works, but when the tooltip is shown when i doucbleclick (to edit) then the tooltip won't disappear, not even after editting.
I need to refresh the page to get rid of the tooltip.

Any ideas?

Here's the piece of code:

Code:
function formatA(value,row,index){
return '<span data-p1='+index+' class="easyui-tooltip">' + value + '</span>';
}
function createTooltip(){
    $('#tt').datagrid('getPanel').find('.easyui-tooltip').each(function(){
        var index = parseInt($(this).attr('data-p1'));
        $(this).tooltip({
            content: $('<div></div>'),
            onUpdate: function(cc){
                var row = $('#tt').datagrid('getRows')[index];
                var content = '<div>'+row.comments+'</div>';
                cc.panel({
                    width:200,
                    content:content
                });
            },
            position:'left'
        });
    });
}

And the datagrid i added these:

<th data-options="field:'comments',width:100,align:'left',sortable:true,formatter:formatA">Opmerkingen</th>

and

 onLoadSuccess function calls "createTooltip()"


Title: Re: Tooltip on edatagrid does not disappear
Post by: stworthy on July 25, 2014, 08:36:30 AM
After edit or cancel a row, please re-create tooltip again on this row. Try the code below:
Code:
$('#tt').edatagrid({
onBeforeEdit:function(index,row){
var opts = $(this).edatagrid('options');
var tr = opts.finder.getTr(this, index);
tr.find('.easyui-tooltip').tooltip('destroy');
},
onAfterEdit:function(index,row){
createTooltip()
},
onCancelEdit:function(index,row){
createTooltip()
},
onLoadSuccess:function(){
createTooltip()
}
});


Title: Re: Tooltip on edatagrid does not disappear
Post by: ShockRaver on July 25, 2014, 10:11:15 PM
Thank you, works great!

tried it with onEdit and onAfterEdit, but didn't think of onBeforeEdit... Think that did the trick :)