⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recordeditor.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 2 页
字号:
    },        // Add the record to the source widget's data object    // This method is not completely functional yet - see comments within the method body    performSave : function (suppressPrompt) {            // ensure we save the value from the current edit field before saving out the        // entire set of values.        var rowNum = this.getEditRow(),            colNum = this.getEditCol(),            fieldName = this.getFieldName(colNum),            newValue = this._editRowForm.getValue(fieldName);        this.setEditValue(rowNum, colNum, newValue);        // validate the entire row, and save only if validation succeeds:        var newValues = this.getEditValues(0),            fields = this.getFields().getProperty(this.fieldIdProperty);        // This method will show the validation errors, and put focus into the field for         // which the validation failed        if (!this.validateRowValues(newValues, {}, 0, fields)) return;                // xxx        // At this point we want to fall through to 'saveEditedValues()', but we need to         // ensure that the saveEditedValues method on the sourceWidget is aware that we        // are adding a record rather than overriding exising records.          // Currently this does not happen, so we will end up overriding existing records//        targetList.saveEditedValues(//            targetList.data.getLength(), 0, null, newValues, {}, isc.ListGrid.PROGRAMMATIC//        );          // clear out existing edit values, and call startEditing again to start a fresh edit              this._clearEditValues(0);        this._startEditing(0,0);        // This ensures the edit form values get cleared out.        for (var fieldName in newValues) {            this.refreshCell(0,colNum);        }    },        // A method to get the current edit-values    getValues : function () {        var colNum = this.getEditCol(),            fieldName = this.getEditFieldName();        this.setEditValue(0, colNum, this._editRowForm.getValue(fieldName));                return isc.addProperties({},this.getEditValues(0));                },        // Inline Editor overrides:    // override canEditCell - if this is a filter we want to look at the static 'canFilter'    // property on the field (inherited from the source widget).  Otherwise just fall through     // to the canEditCell implementation on the sourceWidget.    canEditCell : function (rowNum, colNum) {        if (this.actionType == "filter") {            var field = this.getField(colNum);            if (field == null) return false;            return (field.canFilter != false);        } else {            return this.sourceWidget.canEditCell(rowNum, colNum);        }    },    // Override the various methods to determine the edit form item properties.    // If this is a filter edit row, we want to use the appropriate 'getFilterEditor...'    // methods on the source widget -- if this is an editor, we simply inherit the     // 'getEditor...' methods from the source widget.        getEditorValueMap : function (field, values) {        if (this.actionType == "filter") {            return this.sourceWidget.getFilterEditorValueMap(field);        } else {            return this.sourceWidget.getEditorValueMap(field, values);        }    },        getEditorType : function (field, values) {        if (this.actionType == "filter") {            return this.sourceWidget.getFilterEditorType(field);        } else {            return this.sourceWidget.getEditorType(field, values);        }    },        // function to re-use as change handler on all our items    _editorChanged : function () {        this.form.grid.editorChanged(this);    },        // Technically this fires on changed, not keypress but it's a cleaner name.    editorChanged : function (item) {        var actOnKeypress = item.actOnKeypress != null ? item.actOnKeypress : this.actOnKeypress;                                   if (actOnKeypress) this.performAction(true);    },        getEditorProperties : function (field) {        // Default all items to match this.cellHeight        var props = {height:this.cellHeight};        // Pick up optionDataSource from the source widget if a field has a specified dataSource        // but no optionDataSource.                if (field.displayField && !field.optionDataSource)             props.optionDataSource = this.sourceWidget.dataSource;                    if (this.actionType == "filter") {            // For filter editors always allow empty values            props.allowEmptyValue = true;            // fire our special changed handler on 'changed'            props.changed = this._editorChanged;              props.actOnKeypress = field.filterOnKeypress;                        return isc.addProperties(props, this.sourceWidget.getFilterEditorProperties(field));        } else {            return isc.addProperties(props, this.sourceWidget.getEditorProperties(field));        }    },            // cellEditEnd() is fired when the user completes an edit for some cell by tabbing out    // of that cell, hitting enter or escape, etc.    // We override the default implementation to avoid cancelling the edit, or saving the    // edit values into this.values, and to allow us to fire our default action in response    // to an enter keypress (or a field change).    cellEditEnd : function (editCompletionEvent, newValue) {        // Possible editCompletionEvents are:        // - CLICK_OUTSIDE - suppressed as we don't show the clickMask for this ListGrid        // - ESCAPE_KEYPRESS - ignore        // - UP_ARROW_KEYPRESS - ignore        // - DOWN_ARROW_KEYPRESS - ignore        // - EDIT_ROW_CHANGE - will not happen as we don't have more than one row        // - PROGRAMMATIC - ignore        //        // - ENTER_KEYPRESS - fire this.performAction - will perform a filter if this        //                    is a filter editor (or a save if this is an editor)        // - TAB_KEYPRESS -         // - SHIFT_TAB_KEYPRESS -         // - EDIT_FIELD_CHANGE -         //              For all field changes, save out the edit values, and move to the         //              appropriate fields.        //              If this.actOnCellChange is true, also fire this.performAction().        if (editCompletionEvent != isc.ListGrid.ENTER_KEYPRESS &&            editCompletionEvent != isc.ListGrid.TAB_KEYPRESS &&             editCompletionEvent != isc.ListGrid.SHIFT_TAB_KEYPRESS &&            editCompletionEvent != isc.ListGrid.EDIT_FIELD_CHANGE) return true;        var undef;        if (newValue === undef) newValue = this.getUpdatedEditorValue();                    var rowNum = this.getEditRow(),            colNum = this.getEditCol();        // update the locally stored edit info with the new value for the appropriate field        this.setEditValue(rowNum, colNum, newValue);        // Save / query on enter keypress        if (editCompletionEvent == isc.ListGrid.ENTER_KEYPRESS || this.actOnCellChange) {            this.performAction();            return;                    }                        var nextCell = this.getNextEditCell(rowNum, colNum, editCompletionEvent);                    if (nextCell == null || nextCell[0] != rowNum) {            // if we're tabbing past the end of the row, we want to put focus onto the            // appropriate object on the page.            // We have to do this explicitly, because we've overridden the key press            // method on the editor form items to suppress the native tab-behavior.            if (editCompletionEvent == isc.ListGrid.TAB_KEYPRESS) {                // we know that the next tab item is the action button.                this._actionButton.focus();            } else {                // On shift tab, move focus to the previous widget in the tab order.                // This assumes that this widget has an auto-assigned tab index.                if (this._previousTabWidget != null) this._previousTabWidget.focus();            }            return;        }                // In this case we want to fall through to the superclass implementation - this        // will validate the cell value (if necessary), save the editValue locally, and        // move focus to the appropriate cell.        // xxx - Could just reimplement the relevant code here rather than calling Super        //       to avoid (EG) calling 'getNextEditCell()' more than once.        return this.Super("cellEditEnd", arguments);    },    // clearEditValue on the superclass will dismiss the editor if no editValues are left.  The    // recordEditor never wants to do this.    clearEditValue : function (editValuesID, fieldName) {        return this.Super("clearEditValue", [editValuesID, fieldName, null, true]);    },    // UI Synching:    // Ensure the action button stays positioned / sized correctly    // Override layoutChildren to keep the action button positioned at the right edge of this    // widget    layoutChildren : function () {        this.Super("layoutChildren", arguments);        // Stick the action button to the left        if (this._actionButton)             this._actionButton.setLeft(this.getInnerWidth() - this.getScrollbarSize())        // Ensure the body does not extend behind the action button - this avoids issues        // where we can't scroll the source widget horizontally to get at stuff under the        // V-Scrollbar        if (this.body)            this.body.setWidth(this.getInnerWidth() - this.getScrollbarSize())    },    // Override adjustOverflow to render the actionButton as tall as this widget    adjustOverflow : function () {        this.Super("adjustOverflow", arguments);        if (this._actionButton) {            this._actionButton.setHeight(this.body.getVisibleHeight());        }                },        // We need to keep our UI in synch with our source widget.    // This means:    // - Show and Hide with source widget.    //      Handled by standard peer relationship    // - Move with source widget    //      Handled by standard peer relationship    // - Resize with source widget, and remain positioned below source widget    //      Handled by ListGrid.resizePeersBy() method    // - Scroll body with the source widget body    //      RecordEditor bodyScrolled() overridden below to keep source widget body in synch     //      with us.    //      ListGrid bodyScrolled() method handles keeping us in synch with source widget body    //      scroll position.    // - Resize fields with the source widget    //      Handled by source widget resizeField()    // - Reorder / Change fields with the source widget       //      Handled by source widget reorderFields()    // Override bodyScrolled() to keep the body scrolling in synch.    // Note that bodyScrolled implementation on the source widget will handle scrolling this    // widget into place.    bodyScrolled : function (left, top) {        this.Super("bodyScrolled", arguments);        // Scroll the sourceWidget body to our position        // Only do this if it's not already scrolled to the same position as us                if (this._syncSourceEvent != null) {            isc.Timer.clear(this._syncSourceEvent);        }        this._syncSourceEvent = this.delayCall("syncSourceScrolling", [], 0);    },        syncSourceScrolling : function () {        var left = this.body.getScrollLeft();        if (this.sourceWidget && this.sourceWidget.body &&             this.sourceWidget.body.getScrollLeft() != left) {                            this.sourceWidget.body.scrollTo(left);        }    },    // override 'getFieldWidths' to get the source's field widths.        getFieldWidths : function () {        var widths = this.sourceWidget.getFieldWidths();        // duplicate the widths so modifications on the LG widths array won't directly effect        // our widths        if (isc.isA.Array(widths)) widths = widths.duplicate();        return widths;    }});//!<Deferred

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -