简体   繁体   English

KenView UI Javascript重绘TreeView不会呈现

[英]Kendo UI Javascript redraw of TreeView not rendering

After creating and rendering a Kendo UI TreeView to fill a DIV, repeat invocation alternately renders only "loading..." or works properly. 创建并渲染Kendo UI TreeView以填充DIV后,重复调用将交替渲染仅“正在加载...”或正常工作。 Since I am having possibly similar problems with Kendo UI ContextMenu, I speculate there may be some required cleanup in between, which is passively done by even invocations such that odd invocations work, but I can't figure it out (a link to Kendo UI docs I might be missing so I can understand why I've missed this would be appreciated to help with other issues). 由于我在Kendo UI ContextMenu中可能遇到类似的问题,因此我推测它们之间可能需要进行一些清理,这是通过偶数调用被动完成的,从而使奇数调用起作用,但我无法弄清楚(指向Kendo UI的链接) docs我可能会丢失,所以我可以理解为什么我错过了它,希望能对其他问题有所帮助)。

In my JSFiddle example, click "draw" over and over and you'll see the alternate behavior. 在我的JSFiddle示例中,一遍又一遍地单击“绘制”,您将看到替代行为。 Speculatively clicking "draw, destroy, draw, destroy..." does not seem to help. 推测性地单击“绘制,销毁,绘制,销毁...”似乎无济于事。

https://jsfiddle.net/rk3nfnnu/ https://jsfiddle.net/rk3nfnnu/

<script>
    function TreeDestroy() { // http://stackoverflow.com/questions/5431351
        $('#Tree_Space').data('kendoTreeView').destroy();
        alert('destroyed');
    }
    function TreeShow() {
        $('#Tree_Space').kendoTreeView({
            dataSource: [ { Name: 'Top', items: [ { Name:'Item' } ] } ],
            template: kendo.template($('#Tree_template').html())
        });
        alert('shown');
    }
</script>

<a href="#" onclick="TreeShow(); return false;">draw</a> |
<a href="#" onclick="TreeDestroy(); return false;">destroy</a>

<div id='Tree_Space'>
</div>

<script type='text/x-kendo-template' id='Tree_template'>
    #= item.Name#
</script>

I have updated that fiddle. 我已经更新了小提琴。 The destroy(); destroy(); method probably only destroys allocated dom elements after the widget was rendered (the nodes). 方法可能仅在渲染小部件(节点)后销毁分配的dom元素。 I doubt it cleans up the wrappers and whatnot. 我怀疑它会清理包装纸等。 In your TreeDestroy() , issue a clear on that element div. TreeDestroy() ,在该元素div上发出清除命令。 Of course, you should call TreeDestroy prior to TreeCreate just in case. 当然,以防万一,您应该在TreeCreate之前调用TreeDestroy。

function TreeDestroy() { // http://stackoverflow.com/questions/5431351
        $('#Tree_Space').data('kendoTreeView').destroy();       
        $('#Tree_Space').html('');
        alert('destroyed');
    }

Here is some kendoui documentation that refers to how to handle manual deletion of widgets. 是一些kendoui文档,涉及如何处理小部件的手动删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM