Comments (10)
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.
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.
@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.
(closed the issue by mistake sorry)
Hi,
I will show you my problem with some screenshots.
First, I'v an empty folder(new)
Then, if I add a row using only loadBranch I get this :
But if I use node._initialize(); just after loadBranch, I have the expected result :
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.
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.
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.
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.
I'm not able to test now but will do it monday at the first hour. Thank you for your work
from jquery-treetable.
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.
Awesome! Thanks again for reporting this. Closing the issue.
from jquery-treetable.
Related Issues (20)
- Uncaught TypeError: Cannot read property 'sort' of undefined.
- Re-init with Force duplicates the expander in the table HOT 1
- browser question ,expandAll
- Rendering tree after reading data from file
- How to use test
- suggest to add method to get all functon names
- Add option to append nodes at top. [PR request pending]
- Reloading/Refreshing treetable on object associated change HOT 4
- Download files do not work. HOT 1
- Example for loading the whole tree via Ajax
- Remove GPLv2 license
- Remove sub-node check is not working on initializing first time tree HOT 1
- Loadnode not loading child to its parent
- onNodeExpand expand called before children added (Duplicate)
- Need more documentation on the JSON format
- Bootstrap styling example, please. HOT 1
- Can't deploy jquery-treetable 2.3.1 to webjars.org
- 404 errors on jQueryUI components
- NPM version different than code on master and has a bug
- error if child node comes before parent node.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-treetable.