Skip to content

Commit

Permalink
Fix addChildren throws error when ext-grid is hidden
Browse files Browse the repository at this point in the history
Close #978
  • Loading branch information
mar10 committed Nov 27, 2019
1 parent 6b94bb5 commit 5d93514
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# BRANCH
* [DEPRECATED] jQuery UI widget methods: use `tree.METHOD()` instead.
* [Fixed] `$.ui.fancytree.getTree()` for Element arg.

# 2.34.0-0 / Unreleased
* TODO: tree.hasFocus() more reliable.
* [DEPRECATED] jQuery UI widget methods:
Use `tree.METHOD()` instead of `$().fancytree("METHOD")`.
* [Added] `tree.debugTime()`, `tree.debugTimeEnd()` for debugging.
* [Added] `tree.destroy()` as shortcut for `tree.widget.destroy()`.
* [Added] `tree.destroy()` as alternative for `tree.widget.destroy()`.
* [Fixed] `$.ui.fancytree.getTree()` for Element arg.
* [Fixed] #973 when use ext-grid in one tree, other tree not use ext-grid has error on click.
* [Fixed] #974 ext-grid: too much output in production mode.
* [Fixed] #975 ext-grid: fix `tree.visitRows()` for empty tree.
* [Fixed] #978 addChildren throws error when ext-grid is hidden.

# 2.33.0 / 2019-10-29
* [Added] event `preInit` (fired before nodes are loaded).
Expand Down
13 changes: 7 additions & 6 deletions src/jquery.fancytree.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,16 @@
// Calculate how many rows fit into current container height
var $table = this.$container,
wrapper = this.scrollWrapper,
trHeight = $table
.find(">tbody>tr")
.first()
.height(),
trHeight =
$table
.find(">tbody>tr")
.first()
.height() || 0,
tableHeight = $table.height(),
headHeight = tableHeight - this.viewport.count * trHeight,
wrapperHeight = wrapper.offsetHeight,
free = wrapperHeight - headHeight,
newCount = Math.floor(free / trHeight);
newCount = Math.floor(free / trHeight) || 0;

This comment has been minimized.

Copy link
@yangjuncode

yangjuncode Nov 28, 2019

trHeight maybe zero in line 284, so here free / trHeight is ok? what i be told is don't div by zero anyway.


// console.info(
// "set container height",
Expand Down Expand Up @@ -797,7 +798,7 @@
// node.warn("nodeRender(): ignoring hidden");
return;
}
node.warn("nodeRender(): creating new TR!");
node.debug("nodeRender(): creating new TR.");
node.tr = tree.tbody.rows[node._rowIdx - start];
}
// _assert(
Expand Down

0 comments on commit 5d93514

Please sign in to comment.