PDA

View Full Version : Wrong CellEditing Numberformat



3xc3ption
3 Apr 2014, 5:11 AM
Hey,

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

48539

Example- Grid

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:

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 ;)

scottmartin
3 Apr 2014, 6:27 AM
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)

3xc3ption
3 Apr 2014, 10:28 PM
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

scottmartin
4 Apr 2014, 4:06 AM
You can use the UX editor in the plugin , or extend and editor and use that... as the xtype.

editor: { xtype: 'mycustomfield' }

3xc3ption
4 Apr 2014, 12:45 PM
Ok, here my fast solution!



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


big thanks