我正在使用其中包含文件上传字段的 ExtJs 表单。
在选择一个文件时,我调用了表单的 submit() 方法。
但在提交之前,我使用 form.isValid() 检查表单是否有效。
现在由于一些未知原因,我将 form.isValid() 设置为 FALSE。
但我想知道为什么表单验证失败?
我将所有其他字段保留为 allowBlank: false。
有没有办法知道(使用方法或配置属性)表单验证失败的原因以及表单中的无效字段(以及消息)是什么?
这是我的代码:
var simple = Ext.create('Ext.form.Panel', {
id : 'textIntConfigPanel',
frame : true,
bodyPadding : 1,
width : '100%',
layout : 'anchor',
fileUpload: true,
items :[{
xtype : 'panel',
layout : 'column',
fieldDefaults : {
labelAlign : 'center',
msgTarget : 'side'
},
items : [{
xtype: 'fieldset',
columnWidth:0.5,
border: false,
items:[{
xtype : 'fieldset',
title: 'Configuration',
flex : 1,
defaultType : 'textfield',
items : [{
xtype : 'radiogroup',
fieldLabel : 'Configuration',
id:'rdType',
columns : 2,
defaults : {
name : 'rdType'
},
items : [{
inputValue : '0',
boxLabel : 'Existing',
checked : true
},{
inputValue : '1',
boxLabel : 'New'
}]
},{
xtype: 'container',
layout: 'hbox',
padding: '0 5 0 0',
items: [{
xtype: 'textfield',
fieldLabel : 'Configuration Name',
name : 'txtConfigName',
id:'txtConfigName',
padding: '0 5 0 0',
hidden:true,
disabled:true
},{
xtype : 'image',
padding: '0 5 0 0',
hidden:true,
id:'nameConfirmation'
}]
},{
name : 'txtOldConfigTable',
id:'txtOldConfigTable',
hidden:true
},{
xtype : 'combobox',
fieldLabel : 'Configuration Name',
name : 'cmbConfigName',
id:'cmbConfigName',
editable:false,
valueField : 'configId',
displayField : 'configName',
emptyText : 'Select Configuration...',
store : configNameStore
},{
xtype : 'radiogroup',
fieldLabel : 'If Data Exists',
id:'ifExists',
columns : 2,
defaults : {
name : 'ifExists'
},
items : [{
inputValue : 0,
boxLabel : 'Update & Insert',
checked : true
},{
inputValue : 1,
boxLabel : 'Insert Only New'
}]
},{
xtype : 'radiogroup',
fieldLabel : 'Location',
id:'rdoLoc',
columns : 3,
defaults : {
name : 'rdoLoc'
},
items : [{
inputValue : '0',
boxLabel : 'Local',
checked : true
},{
inputValue : '1',
boxLabel : 'HTTP'
},{
inputValue : '2',
boxLabel : 'FTP'
}]
},{
fieldLabel : 'File Location',
name : 'txtFileLoc',
disabled:true,
hidden:true,
id:'txtFileLoc'
},{
fieldLabel : 'User Name',
name : 'txtUserName',
disabled:true,
hidden:true,
id:'txtUserName'
},{
fieldLabel : 'Password',
name : 'txtPassword',
inputType :'password',
disabled:true,
hidden:true,
id:'txtPassword'
}]
},{
xtype : 'fieldset',
title: 'Scheduling',
flex : 1,
defaultType : 'textfield',
layout : 'vbox',
items:[{
xtype : 'fieldset',
flex : 1,
border:false,
padding :0,
margin:0,
defaultType : 'textfield',
width : '100%',
layout : 'hbox',
items:[{
xtype : 'fieldset',
flex : 1,
border:false,
padding :0,
margin:0,
defaultType : 'textfield',
width : 50,
layout : 'anchor',
items:[{
xtype : 'combobox',
fieldLabel : 'Repeat Type',
name : 'cmbRptType',
id:'cmbRptType',
editable:false,
labelWidth : 90,
width : 180,
store:[['0','Never'],['1','Hourly'],['2','Daily'],['1','Monthly']],
displayField: 'val',
valueField: 'key',
emptyText : 'Select RepeatType...'
},{
xtype : 'textfield',
fieldLabel : 'Repeat Interval',
name : 'txtRptInc',
labelWidth : 90,
width : 150,
id:'txtRptInc',
regex: /^[1]?[0-9]{0,1}$/,
regexText: "<b>Error</b></br>Increment Must be Integer"
}]
},{
xtype : 'fieldset',
border:false,
padding :'0 0 8 0',
margin:0,
flex : 1,
defaultType : 'textfield',
width : 20,
layout : 'anchor',
defaults : {
anchor : '100%',
hideEmptyLabel : false
},
items:[Ext.create('Ext.ux.form.DateTimeField', {
xtype : 'textfield',
name : 'exeStartDateTime',
id : 'exeDateTime',
labelWidth : 100,
width : 35,
fieldLabel : 'Start Date Time'
})
,Ext.create('Ext.ux.form.DateTimeField', {
xtype : 'textfield',
name : 'exeEndDateTime',
id : 'exeEndDateTime',
labelWidth : 100,
width : 35,
fieldLabel : 'End Date Time'
})]
}]
}]
}]
},{
xtype : 'fieldset',
title: 'Data Preparation',
flex : 1,
defaultType : 'textfield',
columnWidth: 0.5,
width : '100%',
layout : 'vbox',
items:[{
xtype : 'fieldset',
flex : 1,
border:false,
padding :0,
margin:0,
defaultType : 'textfield',
width : '100%',
layout : 'hbox',
items:[{
xtype : 'fieldset',
flex : 1,
border:false,
padding :0,
margin:0,
defaultType : 'textfield',
layout : 'anchor',
items:[{
fieldLabel : 'File Name Pattern',
name : 'txtfileNamePatern',
id:'txtfileNamePatern',
value: '*.*'
},{
xtype: 'container',
layout: 'hbox',
items: [{
xtype: 'filefield',
name : 'fileUploadBox',
id:'fileUpload',
vtype : 'file',
width: 250,
fieldLabel : 'Upload File',
buttonText: 'Browse',
listeners : {
change : function(s, v, o) {
fileName = v;
var form = this.up('form');
debugger;
form.submit({
url : 'textFileIntegrationConfig_!readFile?fileName=' + fileName,
data : {
fileName : fileName
},
success : function(fp, o) {
debugger;
var response = JSON.parse(o.response.responseText);
},
failure : function(fp, o) {
debugger;
var response = JSON.parse(o.response.responseText);
}
});
}
}
},{
xtype : 'image',
hidden:true,
id:'uploadConfirmation'
}]
}]
},{
xtype : 'fieldset',
border:false,
padding :'0 0 8 0',
margin:0,
flex : 1,
defaultType : 'textfield',
width : 300,
layout : 'anchor',
defaults : {
anchor : '100%',
hideEmptyLabel : false
},
items:[{
xtype: 'container',
layout: 'hbox',
items: [{
xtype : 'combobox',
fieldLabel : 'Data Delimiter',
name : 'cmbFieldDelim',
id:'cmbFieldDelim',
margin: '5 5 5 0',
editable:false,
width: 200,
store:[["\\t",'Tab'],["\\n",'New Line'],['99','Other']],
displayField: 'val',
valueField: 'key'
},{
xtype: 'textfield',
name : 'txtFieldDelim',
id : 'txtFieldDelim',
enforceMaxLength: false,
hidden: true,
margin: '5 0 0 0',
maxLength: 2,
width: 50,
validateOnChange : true,
validator: function(v) {
var txtFieldDelim = Ext.ComponentQuery.query("textfield[name='txtRecordDelim']")[0];
if (v == txtFieldDelim.value) {
return "Both Delimiter can't be same";
}
return true;
}
}]
},{
xtype: 'container',
layout: 'hbox',
items: [{
xtype : 'combobox',
fieldLabel : 'Row Delimiter',
name : 'cmbRecordDelim',
id:'cmbRecordDelim',
editable:false,
margin: '0 5 5 0',
width: 200,
store:[['\\r','Tab'],['\\n','New Line'],['99','Other']],
displayField: 'val',
valueField: 'key'
},{
xtype: 'textfield',
name : 'txtRecordDelim',
id : 'txtRecordDelim',
enforceMaxLength: false,
hidden: true,
maxLength: 2,
width: 50,
validateOnChange : true,
validator: function(v) {
var txtFieldDelim=Ext.ComponentQuery.query("textfield[name='txtFieldDelim']")[0];
if(v==txtFieldDelim.value){
return "Both Delimiter can't be same";
}
return true;
}
}]
}]
}]
},{
xtype : 'gridpanel',
flex : 1,
autoSync:false,
autoScroll:true,
id: 'configGrid',
width : '100%',
height:180,
columns: [{
xtype: 'gridcolumn',
flex: 0.33,
text: 'File Header Name',
sortable: false,
menuDisabled: true,
dataIndex: 'header'
},{
text: 'Field Type',
flex: 0.33,
menuDisabled: true,
dataIndex: 'dataType'
},{
text: 'Table Field Name',
flex: 0.33,
menuDisabled: true,
dataIndex: 'finalFieldName',
editor: 'textfield'
}],
store : gridStore,
plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})]
}]
}],
tbar: ['->', {
text : 'Save',
icon: "images/icon-save.gif",
handler : function() {
var form=this.up('form');
formAllowBlank(false);
if (form.getForm().isValid()) {
Ext.MessageBox.show({
msg : 'Saving data, please wait...',
progressText : 'Saving...',
width : 300,
wait : true,
waitConfig : {
interval : 200
}
});
saveData(form);
}
}
},{
text : 'Test & Run Now',
id: 'Integration.TestBtn',
icon: "images/run.png",
handler : function() {
var form=this.up('form');
TestData(form);
}
}, {
text : 'Reset',
icon: "images/cross.png",
handler : function() {
resetData();
}
} ]
}]
});
最佳答案
这里有一个更简单的解决方案:
form.query("field{isValid()==false}")
关于javascript - ExtJs:表单 isValid() 为假。但是如何知道表单无效的原因呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19354433/
我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div
总的来说,我对ruby还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
Rackup通过Rack的默认处理程序成功运行任何Rack应用程序。例如:classRackAppdefcall(environment)['200',{'Content-Type'=>'text/html'},["Helloworld"]]endendrunRackApp.new但是当最后一行更改为使用Rack的内置CGI处理程序时,rackup给出“NoMethodErrorat/undefinedmethod`call'fornil:NilClass”:Rack::Handler::CGI.runRackApp.newRack的其他内置处理程序也提出了同样的反对意见。例如Rack
在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/
为什么4.1%2返回0.0999999999999996?但是4.2%2==0.2。 最佳答案 参见此处:WhatEveryProgrammerShouldKnowAboutFloating-PointArithmetic实数是无限的。计算机使用的位数有限(今天是32位、64位)。因此计算机进行的浮点运算不能代表所有的实数。0.1是这些数字之一。请注意,这不是与Ruby相关的问题,而是与所有编程语言相关的问题,因为它来自计算机表示实数的方式。 关于ruby-为什么4.1%2使用Ruby返