Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.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表单getValues转换为int一些值_Extjs_Extjs4_Extjs4.1_Extjs4.2_Extjs Mvc - Fatal编程技术网

ExtJS表单getValues转换为int一些值

ExtJS表单getValues转换为int一些值,extjs,extjs4,extjs4.1,extjs4.2,extjs-mvc,Extjs,Extjs4,Extjs4.1,Extjs4.2,Extjs Mvc,我有一个带有几个字段的搜索表单(ExtJS 4.2): xtype: 'fieldcontainer', layout: 'hbox', items: [{ xtype: 'combobox', itemId: 'cboEmployee', width: 400, store: cboEmployeeStore, cls: 'arigth', displayField: 'Fu

我有一个带有几个字段的搜索表单(ExtJS 4.2):

xtype: 'fieldcontainer',
layout: 'hbox',

    items: [{

         xtype: 'combobox',
         itemId: 'cboEmployee',
         width: 400,
         store: cboEmployeeStore,
         cls: 'arigth',
         displayField: 'FullName',
         valueField: 'EmployeeId',
         queryMode: 'remote',
         fieldLabel: 'Employee',
         editable: true,
         hideTrigger: true,
         queryParam: 'searchStr',
         name: 'EmployeeId',
         minChars: 3,
         listConfig: {
             loadingText: 'Searching...',
             // Custom rendering template for each item
             getInnerTpl: function() {
                 return '<b>{EmployeeNumber}</b> / {FullName}';
             }
         }


     }, {
         xtype: 'datefield',
         fieldLabel: 'From',
         name: 'FromDate',
         format: 'd/m/Y',
         submitFormat: 'Y-m-d H:i:s',
         width: 180,
         labelWidth: 50,
         cls: 'arigth',
         value: new Date()
     }, {
         xtype: 'datefield',
         fieldLabel: 'To',
         name: 'ToDate',
         format: 'd/m/Y',
         submitFormat: 'Y-m-d H:i:s',
         width: 165,
         labelWidth: 25,
         cls: 'arigth',
         value: new Date()

     }, {
         xtype: 'button',
         action: 'search',
         text: 'Search',
         margin: '0 0 0 20'
     }]
我不能这样做:
form.getValues()
因为我将
EmployeeId=“”
EmployeeId
必须是
整数

这就是我实现每个
语句的原因,但是

当项目为字段集类型时,我会收到一个错误,因为
f.getName()
未定义,所以我不知道这是否是在
EmployeeId
字段值为“”时设置
EmployeeId=0
的最佳方法(空字符串)


如果您需要
EmployeeId
为0(如果它是空字符串),那么在获取所有表单值后只需执行该检查。此外,通过使用表单的
getFieldValues
函数,可以将字段值作为其实际类型,而不是全部作为字符串

// this assumes form is the FormPanel
var formValues = form.getForm().getFieldValues();
// check if the EmployeeId value is null/undefined/""
if(!formValues['EmployeeId']) {
    formValues['EmployeeId'] = 0;
}

简单但很棒…我不知道getForm().getFieldValues()是的,我在几个月前才发现,在使用Ext两年后。
// this assumes form is the FormPanel
var formValues = form.getForm().getFieldValues();
// check if the EmployeeId value is null/undefined/""
if(!formValues['EmployeeId']) {
    formValues['EmployeeId'] = 0;
}