开发者

jQuery treeTable saving state on page refresh

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. ther开发者_如何学Pythone 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


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 :

$("#demo")
.bind("before.jstree", function (e, data) {
    $("#alog").append(data.func + "<br />");
})
.jstree({
    // List of active plugins
    "plugins" : [
        "themes","json_data","ui","crrm","cookies","dnd",
        "search","types","hotkeys","contextmenu"
    ],


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


$('#treetable').treetable({ expandable: true, initialState: 'Expand' }, true);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜