jQuery treeTable 在页面刷新时保存状态
我正在使用 jquery treetable 插件将我的数据显示为表中的树视图。我在网上找不到有关此插件的详细文档。我需要的是,如果用户展开总和节点,然后重新打开或刷新页面,则节点展开应处于先前的状态(即,展开的节点应保持展开状态,而不是折叠到其父节点中)。在这个阶段,我有要扩展的节点名称,存储在 cookie 中,但我不知道如何使用这个 jQuery 插件,因为我对 jQuery 语法没有很好的掌握。这个插件中有一个函数,
// Reveal a node by expanding all ancestors
$.fn.reveal = function() {
$(ancestorsOf($(this)).reverse()).each(function() {
initialize($(this));
$(this).expand().show();
});
return this;
};
我认为它可能对实现我的目标有用......但我不知道如何使用它,或更改它或从 :S 调用它
I am using the jquery treetable plugin for showing my data as a tree view in a table. I dint find a detailed documentation about this plugin on the net. What i need is if the user expands sum nodes and then he reopens or refreshes the page the node expansion shud be in its previous state (i.e the nodes that were expanded shud remain expanded instead of collapsing into their parent nodes). at this stage i hav the node names to expand, stored in the cookie but i dont know how to mess with this jQuery plugin since i dont have a gud grasp of jQuery syntax. there is a function in this plugin as
// Reveal a node by expanding all ancestors
$.fn.reveal = function() {
$(ancestorsOf($(this)).reverse()).each(function() {
initialize($(this));
$(this).expand().show();
});
return this;
};
which i think might be useful for achieving my goal...but i hav no idea hw to use this, or alter this or call it from :S
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我最初开始使用这个插件,并且喜欢将附加数据移动到其他列(例如文件大小或描述)的功能。我把它全部撕掉,因为我喜欢语义嵌套的 ul 结构。它最终拥有了许多出色的功能,包括 COOKIE 支持。如果您愿意放弃表格视图,我也会考虑切换。这是演示页面JSTREE DEMOS。我相信最后一个使用了 cookie 插件等。向许多事件添加侦听器的功能也非常强大。我在半天内完成了基于拖放 MySQL 的文件系统设置。我最终不得不删除一些插件(包括上下文菜单...让用户右键单击重命名/删除/等...),因为它几乎有太多的功能!
显示插件并添加漂亮的事件侦听器的代码片段:
I originally started using this plugin and liked the ability to move additional data into other columns (like file sizes or descriptions). I ripped it all out because I liked the semantic nested ul structure. It ended up having a lot of great features INCLUDING COOKIE support. If you are comfortable giving up the table view I would look into switching as well. Here is the demo page JSTREE DEMOS. The last one I believe uses the cookie plugin amongst others. The ability to add listeners to many of it's events is also very powerful. I got a drag and drop MySQL based filesystem setup in half a days work. I ended up having to remove some plugins (including the context menu... lets users right click to rename/delete/etc..) because it had almost too many features!
Code Snippet showing plugins and adding nice event listeners :
明白了...只需从 javascript 对存储在 cookie 中的所有元素调用
$(nodeElement).reveal()
('nodeElement' 来自 cookie),下次刷新时,所有内容都会在它之前的状态got it...just call
$(nodeElement).reveal()
from the javascript on all the elements stored in the cookie('nodeElement' comes from the cookie) and on next refresh everything will be in its previous state