Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs 如何从isDirty()检查中排除字段?_Extjs - Fatal编程技术网

Extjs 如何从isDirty()检查中排除字段?

Extjs 如何从isDirty()检查中排除字段?,extjs,Extjs,我有一个表格,上面有我提交的一些字段。 一个字段不应直接修改,而应通过GUI(它是一个简单的表达式,如“a eq B”或“C包含D”) 所以我有两个组合框(A,B,C,D),(eq,contains,notcontains)和一个文本字段。 当组合框和文本字段中发生更改时,我会向该只读字段写入一个值 问题是,form.isDirty()将这些字段考虑在内。我想排除它们。最简单的方法可能是覆盖表单或字段isDirty方法。根据您选择的内容,它可能会影响表单处理的其他方面 请参见中的示例 覆盖表单(

我有一个表格,上面有我提交的一些字段。 一个字段不应直接修改,而应通过GUI(它是一个简单的表达式,如“a eq B”或“C包含D”)

所以我有两个组合框(A,B,C,D),(eq,contains,notcontains)和一个文本字段。 当组合框和文本字段中发生更改时,我会向该只读字段写入一个值


问题是,form.isDirty()将这些字段考虑在内。我想排除它们。

最简单的方法可能是覆盖表单或字段
isDirty
方法。根据您选择的内容,它可能会影响表单处理的其他方面

请参见中的示例

覆盖表单(请参阅):

覆盖字段:


最简单的方法可能是重写表单或字段
isDirty
方法。根据您的选择,它可能会影响表单处理的其他方面

请参见中的示例

覆盖表单(请参阅):

覆盖字段:


另一种方法是:

var form2 = new Ext.form.Panel({
renderTo: Ext.getBody(),
items: [{
    xtype: 'textfield'
    ,name: 'testField'
    ,fieldLabel: 'Test field'
},{
    xtype: 'textfield'
    ,name: 'ignoredField'
    ,fieldLabel: 'Ignored Field'
    ,listeners: {
        change: function(fld) {
           fld.resetOriginalValue();
        }
     }
}],
buttons: [{
    text: 'Is dirty?'
    ,handler: function() {
        alert(form2.isDirty());
    }
}]
});

另一种方法是:

var form2 = new Ext.form.Panel({
renderTo: Ext.getBody(),
items: [{
    xtype: 'textfield'
    ,name: 'testField'
    ,fieldLabel: 'Test field'
},{
    xtype: 'textfield'
    ,name: 'ignoredField'
    ,fieldLabel: 'Ignored Field'
    ,listeners: {
        change: function(fld) {
           fld.resetOriginalValue();
        }
     }
}],
buttons: [{
    text: 'Is dirty?'
    ,handler: function() {
        alert(form2.isDirty());
    }
}]
});

如果希望字段与表单完全分离,可以将字段的isFormField属性设置为false。

如果希望字段与表单完全分离,可以将字段的isFormField属性设置为false

var form2 = new Ext.form.Panel({
renderTo: Ext.getBody(),
items: [{
    xtype: 'textfield'
    ,name: 'testField'
    ,fieldLabel: 'Test field'
},{
    xtype: 'textfield'
    ,name: 'ignoredField'
    ,fieldLabel: 'Ignored Field'
    ,listeners: {
        change: function(fld) {
           fld.resetOriginalValue();
        }
     }
}],
buttons: [{
    text: 'Is dirty?'
    ,handler: function() {
        alert(form2.isDirty());
    }
}]
});