Results 1 to 5 of 5

Thread: Wrong CellEditing Numberformat

  1. #1
    Sencha User
    Join Date
    May 2009
    Posts
    11

    Default Answered: Wrong CellEditing Numberformat

    Hey,

    i use the Ext.grid.plugin.CellEditing Plugin. It works fine, but if i click in a cell, it shows the wrong format!

    2014-04-03 15_03_54.png

    Example- Grid
    Code:
    Ext.define('myApp.view.SGrid', {    
        extend: 'Ext.grid.Panel',
        alias: 'widget.sgrid',
    
    
        requires: [
            'Ext.selection.*',
            'Ext.grid.*',
            'Ext.data.*',
            'Ext.util.*',
            'Ext.state.*',
            'Ext.form.*',
            'Ext.ux.CheckColumn',
            'Ext.toolbar.Paging'
        ],
    
    
        autoScroll: true,
        title: 'MyGrid',
        initComponent: function() {
            var me = this;
            
            var sm = Ext.create('Ext.selection.CheckboxModel',{
                checkOnly : true,
                selType: 'cellmodel'
            });
            
             // CellEditing
            var cellEditing =  Ext.create('Ext.grid.plugin.CellEditing', {
                clicksToEdit: 1,
                pluginId: 'editing'
            });
            
            Ext.applyIf(me, {
                columns: [
                    {dataIndex:'weight_1', text:'weight_1', xtype: 'numbercolumn', renderer: function(e){
                        return Ext.util.Format.number(e, '0,000.000');
                    }, format:'0,000.000', editor: {allowBlank: true, format: '0,000.000' } },
                    {dataIndex:'weight_2', text:'weight_2', xtype: 'numbercolumn', format:'0,000.000', editor: {allowBlank: true } },
                ]],
                    // CellEditing Plugin
                    plugins: [cellEditing],
                    ........ other stuff .....
            });
            me.callParent(arguments);
            }
    });
    Model:
    Code:
    Ext.define('myApp.model.Weight', {    
       extend: 'Ext.data.Model',
    
    
        requires: [
            'Ext.data.Field',
            'Ext.data.Types'
        ],
         fields: [
             {name: 'weight_1', type: 'float'},
             {name: 'weight_2', type: 'float'}
         ]
    
    });
    What do i wrong?

    Thanks for reading and help

  2. You would have to format your editor field.
    http://www.sencha.com/forum/showthread.php?147962

    Keep in mind that a grid cell rending function where you format your data is not obeyed by the cell editor. It loads a separate numberfield editor (like on any form)

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    You would have to format your editor field.
    http://www.sencha.com/forum/showthread.php?147962

    Keep in mind that a grid cell rending function where you format your data is not obeyed by the cell editor. It loads a separate numberfield editor (like on any form)

  4. #3
    Sencha User
    Join Date
    May 2009
    Posts
    11

    Default

    Hi Scott,

    thanks for your reply.
    Ok i know now i have to format the editor field, but i dont know how ...

    Your example (NumericField) extend Ext.form.field.Number !
    I'm not sure what i have to do, should i extend the numbercolumn or the editorplugin

    You have a hint or a code snippet for me?

    thanks
    3xc3ption

  5. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    You can use the UX editor in the plugin , or extend and editor and use that... as the xtype.

    editor: { xtype: 'mycustomfield' }

  6. #5
    Sencha User
    Join Date
    May 2009
    Posts
    11

    Default

    Ok, here my fast solution!

    Code:
    getEditor: function(record){                        
                   return Ext.create('Ext.ux.form.NumericField',
                                {
                                    fieldLabel: '',
                                    allowNegative: false,
                                    allowDecimals: true,
                                    labelWidth: 50,
                                    decimalSeparator: ',',
                                    decimalPrecision: 3
                                })
    }
    big thanks

Posting Permissions

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