重置表单字段的原始值

时间:2019-11-13 16:58:45

标签: extjs

我有一个resetFormOnNewButtonClick方法,该方法可以在单击按钮时重置表单。但是不幸的是,此方法仅重置表单,而不重置字段的原始值,因此我的表单总是脏的。有人可以帮助我进行重置字段的原始值?

 resetFormOnNewButtonClick: function (form, me) {
    if (!form) return;
    var durationControls = form.query('durationfield');
    var newDurationControls = [];
    var tmZone = Webvision.utils.CommonUtils.getEntryTimeZone(form.xtype);
    if (durationControls) {
        for (var i = 0; i < durationControls.length; i++) {
            newDurationControls.push(Ext.clone(durationControls[i].getDefaultValue() != null ? durationControls[i].getDefaultValue() : durationControls[i].getValue()));
        }
    }
    var fieldItems = form.getForm().getFields().items;
    form.isBtnPressed = true;
    var filterFields = [];
    for (var i = 0; i < fieldItems.length; i++) {
        if (fieldItems[i].up('panel').up('#itemsPresenterBar') == undefined) {
            filterFields.push(fieldItems[i]);
        }
        fieldItems[i].resetOriginalValue();
        if (fieldItems[i].xtype == "oatitimezone") {
            fieldItems[i].originalValue = tmZone;
        }
    }
    form.getForm().getFields().items = filterFields;
    errorView = form.down('#errorList');
    form.customParams = null;
    form.getForm().reset();

    if (Wv.CommonUtils.getIfAvailable(form, ".updateSubsriberEntityKey")) {
        form.updateSubsriberEntityKey(null);
    }

    if (newDurationControls) {
        for (var i = 0; i < newDurationControls.length; i++) {
            if (durationControls[i]) {
                durationControls[i].setCustomTimeZone(tmZone);
                durationControls[i].setValue(newDurationControls[i]);
            }
        }
    }

    if (form.getController().onNewButtonClick instanceof Function) {
        form.getController().onNewButtonClick();
    }

    form.IsEnableReasonForChange=false;
    form.lookupReference('copyBtn').hide();
    form.lookupReference('deleteBtn').hide();
    form.setConfig('isEditableMode', false);
    form.getForm().clearInvalid();
    delete form.getController().hasSavePressed;
    errorView.setErrors([]);
    me.fireEvent('onNewClick', form);

    var applicationConfig = Wv.GlobalVar.getApplicationConfig();
    var extensionDisplay = applicationConfig.ExtensionDisplays;
    for (var k in extensionDisplay) {
        var value = form.query('[xtype=' + extensionDisplay[k] + ']');
        if (value && value.length > 0) {
            var extension = value[0];
            if (extension && extension.events.onnewbuttonclick) {
                extension.fireEvent("onNewButtonClick", form);
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您可能正在寻找取决于trackResetOnLoad配置的加载/绑定方式。

trackResetOnLoad