Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to refresh data? #128

Closed
sapien99 opened this issue Feb 21, 2014 · 3 comments
Closed

how to refresh data? #128

sapien99 opened this issue Feb 21, 2014 · 3 comments
Labels

Comments

@sapien99
Copy link

Hi guys,

i like treetable a lot, but i ran into a little issue: i need to refresh the treetable periodically, showing a status-view of some nested services.
The initial setup of the tree works fine, the table is expandable and shows the list of services in a nested structure.
The problem starts when refreshing the tree periodically looping over the services and recreating the innerHTML of the to change the status of the service. createServiceRow just creates a string containing the td-elements.

_.forEach(service,function(service) { $('#'+service.id).html(createServiceRow(service)); })

This results in completely loosing the table structure. What seems to be weird for me: the data-tt-id and data-tt-parent-id are still on the tr, but still everything is renderes as a plain table without nesting.

doing a $('#'+tableId).treetable({expandable:true},true);

and forcing the table recreation works, but constantly collapses/expands the table.

Is the only option to force the recreation and store info about the expanded nodes to expand them after the recreation or is there a simple method to refresh table data and reflect it on the treetable?

Taking a look at how treetable renders a nested row i guess i have an explanation why this happens:

<tr id="s2" data-tt-id="s1" data-tt-parent-id="s1" class="collapsed leaf" style="display: table-row;"><td><span class="indenter" style="padding-left: 19px;"></span>nok</td><td>unknown</td></tr>

changing the innerhtml of the tr i also loose the which is created by treetable to render a nested row - but how can i prevent this? i tried to rerender the node after the refresh using treetable("node",id).render(), but that does not change anything :-( What am i doing wrong?

Thanks a lot and Cheers
Michi

@ludo
Copy link
Owner

ludo commented Mar 2, 2014

Are you trying to update only parts of the table? Have you tried using the loadBranch and unloadBranch functions?

@ludo ludo added the support label Mar 2, 2014
@sapien99
Copy link
Author

sapien99 commented Mar 2, 2014

Yes, i use them to apply new childnodes and they work perfect. I found a
solution to update existing td-tags - but honestly i do not know if i did
right: i wrap "my" content with a span-tag with a certain class assigned,
and when refreshing the content i use jquery's .html-function to replace
the inner-html. That leaves the generated spans intact....

Would you suggest such an approach? At least it works, also from a
performance perspective i found no issues right now....

Cheers
Michael
Am 02.03.2014 16:51 schrieb "Ludo van den Boom" notifications@github.com:

Are you trying to update only parts of the table? Have you tried using the
loadBranch and unloadBranch functions?

Reply to this email directly or view it on GitHubhttps://github.com//issues/128#issuecomment-36457383
.

@ludo ludo closed this as completed Mar 7, 2016
@achapman77
Copy link

achapman77 commented Sep 5, 2019

I was also trying to rebuild/refresh all elements within <table> tags. However, it appears <table> holds on to instance of tabletree if previously called on it. Calling tabletree again on <table> does not override. May be a bit hacky, but found destroying <table> and rebuilding entire table within a table container does the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants