Results 1 to 7 of 7

Thread: Hi , how can i set null for a numberfield ?

  1. #1
    Sencha User masoud_tamizy's Avatar
    Join Date
    Oct 2011
    Posts
    108
    Answers
    1
    Vote Rating
    0
      0  

    Default Answered: Hi , how can i set null for a numberfield ?

    Hi , how can i set null for a numberfield ?
    generally it show "0" in numberfield

  2. Let try by changing type of these fields to 'auto' in your model definition. Ex:
    Code:
    Ext.define('Your model here', {
        extend: 'Ext.data.Model',
        fields: [
            ...
            {name: 'job_phone', type: 'auto'},
            {name: 'mobile', type: 'auto'},
            {name: 'fax', type: 'auto'},
            ...
        ]
    });

  3. #2
    Sencha User
    Join Date
    Dec 2011
    Location
    New york, NY
    Posts
    16
    Answers
    1
    Vote Rating
    0
      0  

    Default

    In the config set the value as empty. Eg: value:' '

  4. #3
    Sencha User masoud_tamizy's Avatar
    Join Date
    Oct 2011
    Posts
    108
    Answers
    1
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by mbharathiraj View Post
    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" !!!

  5. #4
    Sencha User
    Join Date
    Dec 2011
    Location
    New york, NY
    Posts
    16
    Answers
    1
    Vote Rating
    0
      0  

    Default

    Can you post the code?

  6. #5
    Sencha User masoud_tamizy's Avatar
    Join Date
    Oct 2011
    Posts
    108
    Answers
    1
    Vote Rating
    0
      0  

    Default

    i post grid section , is it enough ?
    Code:
    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 ...
    untitled.jpg
    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 !!!

  7. #6
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    117
      0  

    Default

    Let try by changing type of these fields to 'auto' in your model definition. Ex:
    Code:
    Ext.define('Your model here', {
        extend: 'Ext.data.Model',
        fields: [
            ...
            {name: 'job_phone', type: 'auto'},
            {name: 'mobile', type: 'auto'},
            {name: 'fax', type: 'auto'},
            ...
        ]
    });

  8. #7
    Sencha User masoud_tamizy's Avatar
    Join Date
    Oct 2011
    Posts
    108
    Answers
    1
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by vietits View Post
    Let try by changing type of these fields to 'auto' in your model definition. Ex:
    Code:
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •