📄 treegrid.js
字号:
var widths = this.Super("getEditFormItemFieldWidths", arguments), treeFieldNum = this.getTreeFieldNum(); widths[treeFieldNum] -= indentSize; return widths;},// return the DataSource for the current record, to allow embedded editinggetRecordDataSource : function (record) { return this.data.getNodeDataSource(record);},//> @method treeGrid.rowClick()//// This override to +link{ListGrid.rowClick()}. This implementation calls through to the// +link{TreeGrid.nodeClick}, +link{TreeGrid.folderClick}, +link{TreeGrid.leafClick} methods, as// appropriate unless the click was on the expand/collapse control of a folder - in which case// those callbacks are not fired.// <p>// Do not override this method unless you need a rowClick callback that fires even when the// user clicks on the expand/collapse control. If you do override this method, be sure to call// <code>return this.Super("rowClick", arguments);</code> at the end of your override to// preserver other handler that are called from the superclass (for example,// +link{ListGrid.recordClick()}.// <p>//// @param record (TreeNode) record that was clicked on// @param recordNum (number) index of the row where the click occurred// @param fieldNum (number) index of the col where the click occurred//// @see TreeGrid.nodeClick()// @see TreeGrid.folderClick()// @see TreeGrid.leafClick()// @see ListGrid.recordClick()//// @visibility external//<rowClick : function (record, recordNum, fieldNum) { var node = record; // if the're clicking in the open area of the list, // it's already been processed properly on mouseDown so just bail if (this.clickInOpenArea(node)) return false; this._lastRecordClicked = recordNum; if (recordNum < 0 || fieldNum < 0) return false; // not in body var node = this.getRecord(recordNum), isFolder = this.data.isFolder(node); if (this.nodeClick) this.nodeClick(this, node, recordNum); if (isFolder) { if (this.folderClick) this.folderClick(this, node, recordNum); } else { if (this.leafClick) this.leafClick(this, node, recordNum); } // execute the super class click method - to pick up field click and recordClick // Note: be sure not to call any handlers the ListGrid will call so as not to get a dup return this.Super("rowClick",arguments);},//> @method treeGrid.recordDoubleClick()//// Handle a doubleClick on a tree node - override of ListGrid stringMethod of same name. If// the node is a folder, this implementation calls +link{TreeGrid.toggleFolder()} on it. If// the node is a leaf, calls +link{TreeGrid.openLeaf()} on it.// // @see listGrid.recordDoubleClick()// @visibility external//<recordDoubleClick : function (viewer, record, recordNum, field, fieldNum, value, rawValue) { // if the're clicking in the open area of the list, // it's already been processed properly on mouseDown so just bail if (this.clickInOpenArea(record)) return false; if (this.data.isFolder(record)) { return this.toggleFolder(record); } else return this.openLeaf(record);}, dataChanged : function () { this.Super("dataChanged", arguments); var folder = this._pendingFolderAnim; if (folder && this.data.isOpen(folder) && this.data.getLoadState(folder) == isc.Tree.LOADED) { this._startFolderAnimation(folder); this._pendingFolderAnim = null; }}, //> @method treeGrid.openLeaf() ([A])// Executed when a leaf node receives a 'doubleClick' event. This handler must be// specified as a function, whose single parameter is a reference to the relevant leaf node in// the tree's data.<br>// See the ListGrid Widget Class for inherited recordClick and recordDoubleClick events.//// @visibility external// @param node (TreeNode) node to open// @see class:ListGrid//<openLeaf : function (node) {},// Drag and Drop// ----------------------------------------------------------------------------------------//> @method TreeGrid.transferDragData() (A)//// This is just like the superclass' transferDragData(), but avoids infinite recursion in the// COPY case by avoiding the _parent key.//// @group dragging, data// update the data object as appropriate on drop.// return the data that was dragged -- the selected records// @return (List of TreeNode) List of TreeNodes that were selected when dragging began//<transferDragData : function() { var selection = this.getDragData(); if (this.dragDataAction == isc.TreeGrid.COPY || this.dragDataAction == isc.TreeGrid.CLONE) { // get a clean copy of the data selection = this.data.getCleanNodeData(selection); } else { selection = this.Super("transferDragData"); } return selection;},// ----------------------------------------------------------------------------------// Customizations of the drag-tracker for tree grids//> @method treeGrid.getDragTrackerIcon()// Return an icon to display as a drag tracker when the user drags some node(s).<br>// Default implementation:<br>// If multiple nodes are selected and +link{TreeGrid.manyItemsImage} is defined, this// image wlll be returned<br>// Otherwise returns the result of +link{TreeGrid.getIcon()} for the first node being // dragged.// <p>// Note: Only called if +link{listGrid.dragTrackerMode} is set to <code>"icon"</code>. // @param records (Array of ListGridRecord) Records being dragged// @return (string) Image URL of icon to display// @group dragTracker// @visibility external//<getDragTrackerIcon : function (records) { var icon; if (records && records.length > 1 && this.manyItemsImage !=null) icon = this.manyItemsImage; else if (records && records[0]) icon = this.getIcon(records[0], true); return icon;},// Override getDragTrackerTitle() to just return the icon and title of the row, not// the indent, opener icon, etc.// Override not currently documented as it's essentially the same as the superclass // implementation - we just reformat the title cell value to avoid it showing the// indent and opener icon.getDragTrackerTitle : function (record, rowNum, a,b,c,d) { var fieldNum = this.getFieldNum(this.getTitleField()); if (fieldNum != this.getTreeFieldNum()) return this.invokeSuper(isc.TreeGrid, "getDragTrackerTitle", record, rowNum, a,b,c,d); // Call the standard listGrids 'getCellValue()' method to give us the formatted title // of the cell being dragged, excluding the TreeGrid folder/file icons, etc. var value = this.invokeSuper(isc.TreeGrid, "getCellValue", record, rowNum, fieldNum); // Now use _getTreeCellTitleArray() to tack on the icon for the node. var titleCell = this._getTreeCellTitleArray(value, record, null, false).join(isc.emptyString); // We need to apply the base (non selected) standard cellStyle/cssText to the drag tracker // table. var cellStyle = this.getCellStyle(record, rowNum, fieldNum); if (this.selection.isSelected(record)) { var styleIndex = this.body.getCellStyleIndex(record, rowNum, fieldNum), standardSelectedStyle = this.body.getCellStyleName(styleIndex, record, rowNum, fieldNum); if (standardSelectedStyle == cellStyle) { styleIndex -= 2; cellStyle = this.body.getCellStyleName(styleIndex, record, rowNum, fieldNum); } } return ["<table class='", cellStyle, "' style='", this.getCellCSSText(record, rowNum, fieldNum), "'><tr>", titleCell, "</tr></table>"].join(isc.emptyString);},//> @method treeGrid.willAcceptDrop() (A)// // This method overrides +link{ListGrid.willAcceptDrop()} and works as follows:// <br><br>// First, +link{ListGrid.willAcceptDrop()} (the superclass definition) is consulted. If it// returns false, then this method returns false immediately.<br>// This handles the following cases:<br>// - reordering of records withing this TreeGrid when +link{ListGrid.canReorderRecords} is true<br>// - accepting dropped records from another dragTarget when +link{ListGrid.canAcceptDroppedRecords} // is true and the dragTarget gives us a valid set of records to drop into place.<br>// - disallowing drop over disabled nodes, or nodes with <code>canAcceptDrop:false</code>// <br>// This method will also return false if the drop occurred over a leaf node whos immediate // parent has <code>canAcceptDrop</code> set to <code>false</code><br>// If +link{TreeGrid.canReparentNodes} is true, and the user is dragging a node from one folder// to another, this method will return true to allow the change of parent folder.<br>// <br><br>// Otherwise this method returns true.//// @group event handling // @return (boolean) true if this component will accept a drop of the dragData//// @visibility external//<willAcceptDrop : function () { // Bail if Superclass willAcceptDrop fails // (Checks that the record is enabled, etc.) if (!this.Super("willAcceptDrop",arguments)) return false; isc._useBoxShortcut = true; // get the record being dropped on var recordNum = this.getEventRecordNum(), newParent = this.data.get(recordNum); isc._useBoxShortcut = false; // dropping in the body in open space means add to root if (newParent == null) newParent = this.data.getRoot(); // if we can't get the new parent, or it can't accept drops, return false if (!newParent || newParent.canAcceptDrop == false) return false; // don't allow drop over non-folder nodes, unless we're allowing record reordering or // canDropOnLeaves is set var isFolder = this.data.isFolder(newParent); if (!isFolder && !(this.canReorderRecords || this.canDropOnLeaves)) return false; // check for dropErrors (dropping record over self, etc.) var moveList = isc.EH.dragTarget.getDragData(); if (!isc.isAn.Object(moveList) || this.getDropError(moveList, newParent) != null) { return false } // Even if we are allowing record reordering, don't allow the user to drop into a // parent with canAcceptDrop explicitly set to false if (!isFolder) { newParent = this.data.getParent(newParent); if (newParent.canAcceptDrop == false) return false; } // If we're dragging data in from another listGrid we're done here // (this relies on canAcceptDropRecords getting checked by the superClass implementation // for this case). if (isc.EH.dragTarget != this) return true; // If we can reorder records, but not reparent, we need to catch the cases where // - records selected currently come from multiple folders // - the drop folder doesn't match the source folder for the node[s] var canReparent = this.canReparentNodes; //>!BackCompat 2006.06.27 if (canReparent == null && this.canAcceptDroppedRecords) canReparent = true; //<!BackCompat if (!canReparent) { if (!isc.isAn.Array(moveList)) moveList = [moveList]; var currentParent; currentParent = this.data.getParent(moveList[0]); if (currentParent != newParent) return false; for (var i = 1; i < moveList.length; i++) { if (currentParent != this.data.getParent(moveList[i])) return false; } } // if we get here, it should be OK! return true;},// Override setUpDragProperties to pick up this.canReparentNodes _setUpDragProperties : function () { // set up our specific drag-and-drop properties this.canDrag = (this.canDrag || this.canDragRecordsOut || this._canDragRecordsToSelf() || this.canDragSelect); this.canDrop = (this.canDrop || this.canDragRecordsOut || this._canDragRecordsToSelf()); this.canAcceptDrop = (this.canAcceptDrop || this.canAcceptDroppedRecords || this._canDragRecordsToSelf());},// allow the user to drag records to self if they can be reordered or reparented_canDragRecordsToSelf : function () { var canReparentNodes = this.canReparentNodes; //>!BackCompat 2006.06.27 if (canReparentNodes == null && this.canAcceptDroppedRecords) { if (!this._canReparentBackcompatNotified) { this.logInfo("'canReparentNodes' is unset. Allowing node reparenting as " + "'canAcceptDroppedRecords' is set to true. For e
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -