Coder Social home page Coder Social logo

Comments (10)

ncrouzier avatar ncrouzier commented on September 17, 2024

I had this problem and fixed it by adding node._initialize(); to the loadRows function.

Tree.prototype.loadRows = function(rows) {

      var node, row, i;
      if (rows != null) {

        for (i = 0; i < rows.length; i++) {
          row = $(rows[i]);

          if (row.data(this.settings.nodeIdAttr) != null) {
            node = new Node(row, this.tree, this.settings);
            this.nodes.push(node);
            this.tree[node.id] = node;

            if (node.parentId != null) {
              this.tree[node.parentId].addChild(node);
            } else {
              this.roots.push(node);
            }
            node._initialize();
          }
        }
      }

      return this;
    };

This might not be the best fix, but it's better than nothing while waiting for an official fix :)

from jquery-treetable.

lilithabaddon avatar lilithabaddon commented on September 17, 2024

Thanks for the fix, but it seems that it does not work if I add node._initialize in the loadRow function but it works as I want if I call it just after loadBranch.
Dunno why it would work for you but not for me.

By the way would you have a solution to add a row on the root element ?

from jquery-treetable.

ludo avatar ludo commented on September 17, 2024

@lilithabaddon is the parent that does not get the expander also a new row? Or did it already exist? And the new children, are they rendered on the screen or not?

Maybe you could add some screenshots illustrating the problem? That would help me understand what you are experiencing.

Regarding your second question, by adding a row on the root element you mean adding new root elements using the loadBranch function? What about being able to do loadBranch(null, rows), would that make sense (note that this does not work right now, but should be possible to add)?

from jquery-treetable.

lilithabaddon avatar lilithabaddon commented on September 17, 2024

(closed the issue by mistake sorry)

Hi,

I will show you my problem with some screenshots.
First, I'v an empty folder(new)

initialisation

Then, if I add a row using only loadBranch I get this :

afterAdding

But if I use node._initialize(); just after loadBranch, I have the expected result :

afterAddingBis

Regarding my second question, I mean adding a new row using loadBranch as you say with a null argument to add at root. I don't know if it is possible to add that but I need a way to do it.

By the way thank you for your answer and for this nice pluggin.

from jquery-treetable.

ludo avatar ludo commented on September 17, 2024

Thanks, the screenshots help a lot. In my own implementation I had the need for a potential folder to already have the expander icon before it would have any children, for this the plugin looks at the data-tt-branch attribute on a node. If you set data-tt-branch="true" on the 'new' folder it should get the expander icon when it is rendered. See the documentation for the branchAttr setting at http://ludo.cubicphuse.nl/jquery-treetable/#api for more information.

Perhaps this is also an adequate solution in your case?

I will create a separate issue for adding a new root node with loadBranch so I can track this feature request more easily.

from jquery-treetable.

lilithabaddon avatar lilithabaddon commented on September 17, 2024

I tried that solution but it appears that it does not work. But if I use expandNode on the parent node jsut after it works fine.

This is the code I use to add a new folder, I call this code as the success callback of an ajax call (I need to update my database)

            var row = "<tr data-tt-branch='true' data-tt-id='folder-"+data.id+"' "+parent+">....</tr>";
            var node = $("#my_reports").treetable("node",'folder-'+data.parent);
    $("#my_reports").treetable("loadBranch",node,row);
    $("#my_reports").treetable("expandNode",'folder-'+data.parent);

Thank you for your fast answer.

from jquery-treetable.

ludo avatar ludo commented on September 17, 2024

I've implemented a fix for this. I'm not happy with the implementation yet, but perhaps you can try with the version from master and see if it fixes your problem? It also includes the ability to add new root nodes, see #56.

from jquery-treetable.

lilithabaddon avatar lilithabaddon commented on September 17, 2024

I'm not able to test now but will do it monday at the first hour. Thank you for your work

from jquery-treetable.

lilithabaddon avatar lilithabaddon commented on September 17, 2024

I've just tested your fix and it seems to work really fine for me. That also fixed a problem I had with addBranch(null,node) wich did not add expander to new node.

Thank you for the time you spent on this pluggin !

from jquery-treetable.

ludo avatar ludo commented on September 17, 2024

Awesome! Thanks again for reporting this. Closing the issue.

from jquery-treetable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.