i load from the database numbers eg. 450.00, 123.33, 500.00 and when i load this values from the grid to form values which is ending .00 has cuted this with enother values is correct but is it possible to load full values even with .00 at the end. I load this by:
grid.on('rowdblclick', function (grid, rowIndex, e) {
var row = grid.getView().getRow(rowIndex);
var record = store.getAt(rowIndex);
simple.form.loadRecord(record);
}
Try the following override:
Ext.override(Ext.form.NumberField, {
setValue : function(v){
v = parseFloat(v);
v = isNaN(v) ? '' : (v.toFixed(this.decimalPrecision)).replace(".", this.decimalSeparator);
Ext.form.NumberField.superclass.setValue.call(this , v);
}
});
I am experiencing the same thing. The NumberField is trimming trailing zeros even though I have specified that I want the decimalprecision to be 3. textfield update:: 39:30 +0200 > format=flowed; > charset=us-ascii > From: Robert Cerny <rcerny at show incrementing > value but it doesnt do anything but on the end http://www.omnigroup.com/mailman/archive/macosx-dev/2001-June/028765.htmlHOME |
So, a number such as '100.000' is automatically trimmed to 100. A number such as '100.001' will be left as '100.001'.
I have also tried reformatting the number (say, changing a '100' to '100.000'), only to have the field once again change trim the zeros off it.
Is there a way to use a numberfield that doesn't trim the zeros?
Introduction to XML Mappings (ELUG) - Eclipsepedia:: In most cases, EclipseLink can determine the target format in the XML document. This example shows how to configure this mapping in Java. http://wiki.eclipse.org/Introduction_to_XML_Mappings_(ELUG)HOME | Serialized Form (Click Extras API):: The show text field option for entering a color hex value. The Class net.sf.click.extras.control.DoubleField extends NumberField implements Serializable http://click.sourceforge.net/docs/extras-api/serialized-form.htmlHOME |
If not, I have to use a textfield with a renderer. Please advise.
Thanks.
hmm..in grid is ok valuses are eg. 450.00 but in the form are without .00 even if i set like you wrote
I was looking for the same and wrote this overwrite:
Ext.override(Ext.form.NumberField, {
/**
* @cfg {Number} fixedPrecision A fixed precision to display after the decimal separator (defaults to -1)
*/
fixedPrecision: -1,
setValue : function(v){
v = typeof v == 'number' ? v : parseFloat(String(v).replace(this.decimalSeparator , "."));
if(isNaN(v)) {
v = '';
} else if(this.fixedPrecision != -1) {
v = v.toFixed(this.fixedPrecision);
}
v = String(v).replace(".", this.decimalSeparator);
Ext.form.NumberField.superclass.setValue.call(this , v);
}
});
1. It is better if your store would contain a float field (not a string)
2. Use a renderer in the column model to display the value with 2 decimals (e.g. using toFixed(2))
3. Use a NumberField with decimalPrecision:2 in the form.
Where's The Advantage In Windows Genuine Advantage?
Stocks Bounce After S&P Joins Bear Market
|