|
@@ -38,12 +38,16 @@ var TREE_SHEET_CONTROLLER = {
|
|
|
|
|
|
controller.prototype.insert = function () {
|
|
|
var newNode = null, that = this;
|
|
|
- if (this.tree && this.tree.selected) {
|
|
|
- newNode = this.tree.insert(this.tree.selected.getParentID(), this.tree.selected.getNextSiblingID());
|
|
|
+ if (this.tree) {
|
|
|
+ if (this.tree.selected) {
|
|
|
+ newNode = this.tree.insert(this.tree.selected.getParentID(), this.tree.selected.getNextSiblingID());
|
|
|
+ } else {
|
|
|
+ newNode = this.tree.insert();
|
|
|
+ }
|
|
|
if (newNode) {
|
|
|
TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
|
|
|
var sels = that.sheet.getSelections();
|
|
|
- var iRow = sels[0].row, newNodeRow = iRow + that.tree.selected.posterityCount() + 1;
|
|
|
+ var iRow = sels[0].row, newNodeRow = that.tree.selected ? iRow + that.tree.selected.posterityCount() + 1 : iRow;
|
|
|
that.sheet.addRows(newNodeRow, 1);
|
|
|
TREE_SHEET_HELPER.refreshTreeNodeData(that.setting, that.sheet, [newNode], false);
|
|
|
that.tree.selected = newNode;
|