如何在Kendo UI Angle 2网格上清除数据 [英] How to clear data on kendo ui angular 2 grid
问题描述
我正在寻找一种方法来清除Angular 2的Kendo UI网格,如果用户浏览另一个页面或只是注销.我曾尝试将可观察对象清除为null
,但这并不好,我毕竟无法填充数据.谁能建议我一个更好的方法?
I'm looking for a way to clear the Kendo UI Grid for Angular 2 if the user navigates another page or simply logout. I have tried clearing the observable to null
and it is not good and i couldn't fill data after all. Can anyone suggest me a better way?
推荐答案
您可以使用=Observable.empty()
或=Observable.from([])
将视图设置为空数组,但是如果要获取数据,则需要重新绑定服务.这就是为什么最简单的方法是只调用.next([])
然后在需要时提取数据的原因.参见此示例
You can set the view to empty array using either =Observable.empty()
or =Observable.from([])
but you will need to rebind the service back again if you want to fetch data. This is why the easiest way will be to just call .next([])
and then when needed fetch the data. See this example
这篇关于如何在Kendo UI Angle 2网格上清除数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!