|
@@ -9,7 +9,7 @@ var TREE_SHEET_CONTROLLER = {
|
|
|
this.sheet = sheet;
|
|
|
this.setting = setting;
|
|
|
this.event = {
|
|
|
- treeSelectedChanged: null
|
|
|
+ refreshBaseActn: null
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -19,13 +19,10 @@ var TREE_SHEET_CONTROLLER = {
|
|
|
TREE_SHEET_HELPER.showTreeData(this.setting, this.sheet, this.tree);
|
|
|
|
|
|
this.sheet.bind(GC.Spread.Sheets.Events.SelectionChanged, function (e, info) {
|
|
|
- that.tree.selected = that.tree.findNode(info.sheet.getTag(info.newSelections[0].row, info.newSelections[0].col));
|
|
|
- if (that.event.treeSelectedChanged) {
|
|
|
- that.event.treeSelectedChanged(that.tree.selected);
|
|
|
- }
|
|
|
+ that.setTreeSelected(that.tree.findNode(info.sheet.getTag(info.newSelections[0].row, info.newSelections[0].col)));
|
|
|
});
|
|
|
|
|
|
- this.sheet.bind(GC.Spread.Sheets.Events.EditEnded, function (sender, args) {
|
|
|
+ /*this.sheet.bind(GC.Spread.Sheets.Events.EditEnded, function (sender, args) {
|
|
|
var result = tree.editedData(setting.cols[args.col].data.field, args.sheet.getTag(args.row, args.col), args.editingText);
|
|
|
|
|
|
if (result.allow) {
|
|
@@ -33,11 +30,11 @@ var TREE_SHEET_CONTROLLER = {
|
|
|
} else {
|
|
|
TREE_SHEET_HELPER.refreshTreeNodeData(that.setting, that.sheet, [tree.findNode(args.sheet.getTag(args.row, args.col))], false);
|
|
|
};
|
|
|
- });
|
|
|
+ });*/
|
|
|
};
|
|
|
|
|
|
controller.prototype.insert = function () {
|
|
|
- var newNode = null, that = this;
|
|
|
+ var newNode = null, that = this, sels = this.sheet.getSelections();
|
|
|
if (this.tree) {
|
|
|
if (this.tree.selected) {
|
|
|
newNode = this.tree.insert(this.tree.selected.getParentID(), this.tree.selected.getNextSiblingID());
|
|
@@ -46,26 +43,22 @@ var TREE_SHEET_CONTROLLER = {
|
|
|
}
|
|
|
if (newNode) {
|
|
|
TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
|
|
|
- var sels = that.sheet.getSelections();
|
|
|
- var iRow = sels[0].row, newNodeRow = that.tree.selected ? iRow + that.tree.selected.posterityCount() + 1 : iRow;
|
|
|
- that.sheet.addRows(newNodeRow, 1);
|
|
|
+ that.sheet.addRows(newNode.serialNo(), 1);
|
|
|
TREE_SHEET_HELPER.refreshTreeNodeData(that.setting, that.sheet, [newNode], false);
|
|
|
- that.tree.selected = newNode;
|
|
|
+ that.setTreeSelected(newNode);
|
|
|
that.sheet.setSelection(newNode.serialNo(), sels[0].col, 1, 1);
|
|
|
that.sheet.showRow(newNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center)
|
|
|
- })
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
controller.prototype.delete = function () {
|
|
|
- var that = this;
|
|
|
+ var that = this, sels = this.sheet.getSelections();
|
|
|
if (this.tree.selected) {
|
|
|
if (this.tree.delete(this.tree.selected)) {
|
|
|
TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
|
|
|
- var sels = that.sheet.getSelections();
|
|
|
- var iRow = sels[0].row;
|
|
|
- that.sheet.deleteRows(iRow, that.tree.selected.posterityCount() + 1);
|
|
|
- that.tree.selected = that.tree.findNode(that.sheet.getTag(iRow, 0, GC.Spread.Sheets.SheetArea.viewport));
|
|
|
+ that.sheet.deleteRows(sels[0].row, that.tree.selected.posterityCount() + 1);
|
|
|
+ that.setTreeSelected(that.tree.findNode(that.sheet.getTag(sels[0].row, 0, GC.Spread.Sheets.SheetArea.viewport)));
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -77,6 +70,9 @@ var TREE_SHEET_CONTROLLER = {
|
|
|
TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
|
|
|
TREE_SHEET_HELPER.refreshNodesVisible([that.tree.selected], that.sheet, true);
|
|
|
that.sheet.showRow(that.tree.selected.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
|
|
|
+ if (that.event.refreshBaseActn) {
|
|
|
+ that.event.refreshBaseActn(that.tree);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -88,37 +84,49 @@ var TREE_SHEET_CONTROLLER = {
|
|
|
TREE_SHEET_HELPER.massOperationSheet(that.sheet, function () {
|
|
|
TREE_SHEET_HELPER.refreshNodesVisible([that.tree.selected.parent], that.sheet, true);
|
|
|
that.sheet.showRow(that.tree.selected.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
|
|
|
+ if (that.event.refreshBaseActn) {
|
|
|
+ that.event.refreshBaseActn(that.tree);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
controller.prototype.upMove = function () {
|
|
|
- var that = this;
|
|
|
+ var that = this, sels = this.sheet.getSelections();
|
|
|
if (this.tree.selected) {
|
|
|
if (this.tree.selected.upMove()) {
|
|
|
TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
|
|
|
- var sels = that.sheet.getSelections();
|
|
|
- var iRow = sels[0].row;
|
|
|
TREE_SHEET_HELPER.refreshTreeNodeData(that.setting, that.sheet, [that.tree.selected, that.tree.selected.nextSibling], true);
|
|
|
that.sheet.setSelection(that.tree.selected.serialNo(), sels[0].col, 1, 1);
|
|
|
+ if (that.event.refreshBaseActn) {
|
|
|
+ that.event.refreshBaseActn(that.tree);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
controller.prototype.downMove = function () {
|
|
|
- var that = this;
|
|
|
+ var that = this, sels = this.sheet.getSelections();
|
|
|
if (this.tree.selected) {
|
|
|
if (this.tree.selected.downMove()) {
|
|
|
TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
|
|
|
- var sels = that.sheet.getSelections();
|
|
|
- var iRow = sels[0].row;
|
|
|
TREE_SHEET_HELPER.refreshTreeNodeData(that.setting, that.sheet, [that.tree.selected, that.tree.selected.preSibling], true);
|
|
|
that.sheet.setSelection(that.tree.selected.serialNo(), sels[0].col, 1, 1);
|
|
|
+ if (that.event.refreshBaseActn) {
|
|
|
+ that.event.refreshBaseActn(that.tree);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ controller.prototype.setTreeSelected = function (node) {
|
|
|
+ this.tree.selected = node;
|
|
|
+ if (this.event.refreshBaseActn) {
|
|
|
+ this.event.refreshBaseActn(this.tree);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
controller.prototype.bind = function (eventName, eventFun) {
|
|
|
this.event[eventName] = eventFun;
|
|
|
};
|