PDA

View Full Version : Hi , how can i set null for a numberfield ?



masoud_tamizy
16 Feb 2012, 7:57 AM
Hi , how can i set null for a numberfield ?
generally it show "0" in numberfield :-?

mbharathiraj
16 Feb 2012, 8:18 AM
In the config set the value as empty. Eg: value:' '

masoud_tamizy
16 Feb 2012, 9:47 AM
In the config set the value as empty. Eg: value:' '
this field used in a row-editing grig ! then when i load a null value from database and show in this numberfield it become "0" !!!

mbharathiraj
16 Feb 2012, 1:17 PM
Can you post the code?

masoud_tamizy
16 Feb 2012, 8:11 PM
i post grid section , is it enough ?


var grid = Ext.create('Ext.grid.Panel', {
layout:'fit',
store: userstore,
selType: 'rowmodel',
loadMask: true,
plugins: [rowEditing],
columns: [{dataIndex: 'national_code',
width: 75,
hideable: false,
header:'کدملی',
sortable:false,
align:'right'
},{ dataIndex:'first_name',
text:'نام',
width: 75,
align:'right',
field: {xtype:'textfield',allowBlank: false, selectOnFocus:true, maxLength:45, enforceMaxLength:true }
},{ dataIndex:'last_name',
text:'نام خانوادگی',
width: 75,
align:'right',
field: {xtype:'textfield', allowBlank: false, selectOnFocus:true, maxLength:45, enforceMaxLength:true}
},{ dataIndex:'father_name',
text:'نام پدر',
width: 75,
align:'right',
field: {xtype:'textfield',allowBlank: false, selectOnFocus:true, maxLength:45, enforceMaxLength:true }
},{ dataIndex:'sh_sh',
text:'شماره شناسنامه',
width: 90,
align:'right',
sortable:false,
field: {xtype:'numberfield',hideTrigger: true, allowBlank: true, mouseWheelEnabled: false, keyNavEnabled: false, allowDecimals:false,selectOnFocus:true, maxLength:10, enforceMaxLength:true}
},{ dataIndex:'sh_s_sh',
width: 125,
text:'شماره سریال شناسنامه',
sortable:false,
align:'right',
field: {xtype:'textfield',allowBlank: true,selectOnFocus:true}
},{ dataIndex:'gender',
text:'جنسیت',
width: 50,
align:'right',
editor: {xtype:'combo', store: sex, editable:false, allowBlank: false, displayField: 'name'}
},{ dataIndex:'birth_date',
text:'تاریخ تولد',
width: 70,
align:'right',
hidden:true,
renderer : function(v){if(v && Ext.isDate(v)){return Ext.PDate.format(v, "Y/m/d");}
return v;
},
editor: {xtype:'pdatefield',editable:false,format: 'Y/m/d',allowBlank: true, selectOnFocus:true, maxLength:10, enforceMaxLength:true, maxValue: new Date()}
},{ dataIndex:'birth_location',
text:'محل تولد',
width: 100,
hidden:true,
align:'right',
field: {type:'textfield',blankText:"محل تولد",allowBlank: true, selectOnFocus:true, maxLength:45, enforceMaxLength:true}
},{ dataIndex:'email',
text:'پست الکترونیک',
width: 150,
hidden:true,
align:'left',
field: {type:'textfield', vtype:'email', allowBlank:true, selectOnFocus:true, maxLength:45, enforceMaxLength:true }
},{ dataIndex:'home_address',
text:'آدرس منزل',
width: 175,
align:'right',
field: {type:'textfield',allowBlank: false, selectOnFocus:true ,maxLength:255, enforceMaxLength:true}
},{ dataIndex:'home_phone',
text:'تلفن منزل',
width: 80,
align:'right',
field: {xtype:'numberfield',hideTrigger: true,allowBlank: false,mouseWheelEnabled: false,keyNavEnabled: false, allowDecimals:false, selectOnFocus:true, maxLength:11,minLength:7, enforceMaxLength:true}
},{ dataIndex:'postal_code',
text:'کدپستی',
width: 75,
align:'right',
field: {xtype:'numberfield',hideTrigger: true,allowBlank: false,mouseWheelEnabled: false,keyNavEnabled: false,allowDecimals:false,selectOnFocus:true,maxLength:10,enforceMaxLength:true}
},{ dataIndex:'job_title',
text:'شغل',
align:'right',
hidden:true,
field: {xtype:'textfield',allowBlank: true,selectOnFocus:true,maxLength:45, enforceMaxLength:true }
},{ dataIndex:'job_address',
text:'آدرس محل کار',
align:'right',
hidden:true,
field: {type:'textfield',allowBlank: true,selectOnFocus:true,maxLength:255, enforceMaxLength:true }
},{ dataIndex:'job_phone',
text:'تلفن محل کار',
align:'right',
width: 80,
hidden:true,
field: {xtype:'numberfield',hideTrigger: true,allowBlank: true,mouseWheelEnabled: false, keyNavEnabled: false ,allowDecimals:false,minLength:7,selectOnFocus:true,maxLength:11, enforceMaxLength:true}
},{ dataIndex:'mobile',
text:'تلفن همراه',
width: 80,
align:'right',
field: {xtype:'numberfield',hideTrigger: true,allowBlank: true,mouseWheelEnabled: false, keyNavEnabled: false,allowDecimals:false, minLength:10,selectOnFocus:true,maxLength:11, enforceMaxLength:true},
hidden:true
},{ dataIndex:'fax',
text:'شماره فکس',
width: 80,
align:'right',
hidden:true,
field: {xtype:'numberfield',hideTrigger: true,allowBlank: true,mouseWheelEnabled: false, keyNavEnabled: false,allowDecimals:false,minLength:7, selectOnFocus:true,maxLength:11, enforceMaxLength:true }
},{ dataIndex:'comment',
text:'توضیحات',
align:'right',
hidden:true,
field: {type:'textfield',allowBlank: true,selectOnFocus:true}
}],
title: 'لیست کاربران حقیقی',
renderTo: Ext.getBody(),
tools: [{ type: 'refresh' ,handler: function(event, toolEl, panel){userstore.load();}}]
});

and i get a pic from grid ...
31805
when inserting , i show a window for insert a new row and specified field can be null, but when it load data from database [null values] , grid showes Zero instead of Null !!!

vietits
16 Feb 2012, 11:14 PM
Let try by changing type of these fields to 'auto' in your model definition. Ex:


Ext.define('Your model here', {
extend: 'Ext.data.Model',
fields: [
...
{name: 'job_phone', type: 'auto'},
{name: 'mobile', type: 'auto'},
{name: 'fax', type: 'auto'},
...
]
});

masoud_tamizy
17 Feb 2012, 1:17 AM
Let try by changing type of these fields to 'auto' in your model definition. Ex:


Ext.define('Your model here', {
extend: 'Ext.data.Model',
fields: [
...
{name: 'job_phone', type: 'auto'},
{name: 'mobile', type: 'auto'},
{name: 'fax', type: 'auto'},
...
]
});

thanks . it works correctly :)