PDA

View Full Version : Format of negative numbers does not work in grid



gisada
29 May 2013, 1:09 AM
Hi

I have a problem where I get the right format inside a grid when the numbers are positive but not when they are negative. Does anyone have any suggestions of what might be Grong with my code?

Gisli.



Ext.define('GridModel', {
extend: 'Ext.data.Model',
fields: [
{type: 'string', name: 'bil_href5'},
{type: 'int', name: 'col_27'}
]
});


Ext.create('Ext.data.Store',{
model: 'GridModel',
storeId: 'GridStore',
data: [
{"bil_href5":"test1","col_27":-1015101},
{"bil_href5":"test2","col_27":-1015101}
]
});


Grid with column:
columns: [{
text: 'Mar13',
dataIndex: 'col_27',
sortable: true,
width: 88,
align:'right',
format :'0,000',
xtype: 'numbercolumn',
filter: {
type: 'numeric'
}
}]

Farish
29 May 2013, 2:58 AM
try it with the code editor in the docs:

http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.grid.column.Number

it seems to work same way for both positive and negative numbers.

gisada
30 May 2013, 1:28 AM
This is strange! It works in the code edotor but not in my browser. This is the whole code from my browser and it does not format the negative number but it formats the positive one:


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Rapport</title>
<script src="http://csjap012.sb1a.sparebank1.no/ExtJS/ext-4.2.1.883/ext-all.js"></script>
<link rel="stylesheet" type="text/css" href="http://csjap012.sb1a.sparebank1.no/ExtJS/ext-4.2.1.883/resources/css/ext-all.css">
<link rel="stylesheet" type="text/css" href="http://csjap012.sb1a.sparebank1.no/ExtJS/ext-4.2.1.883/examples/ux/grid/css/GridFilters.css" />
<link rel="stylesheet" type="text/css" href="http://csjap012.sb1a.sparebank1.no/ExtJS/ext-4.2.1.883/examples/ux/grid/css/RangeMenu.css" />
<script type="text/javascript">
Ext.onReady(function() {
Ext.util.Format.thousandSeparator = '.';
Ext.util.Format.decimalSeparator = ',';
Ext.create('Ext.data.Store',{
storeId: 'GridStore',
fields:[
{ name: 'bil_href5', type: 'string' },
{ name: 'col_27', type: 'int' }
],
data: [
{"bil_href5":"test1","col_27":1015101},
{"bil_href5":"test2","col_27":-1015101}
]
});
Ext.create('Ext.grid.Panel', {
title: 'Test',
store: 'GridStore',
columns: [
{ text: 'Bilag', dataIndex: 'bil_href5'},
{ text: 'Mars13', dataIndex: 'col_27', xtype: 'numbercolumn', format :'0,000'}
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});
})
</script>
<body>
</body>
</html>

gisada
30 May 2013, 6:42 AM
This is a problem that comes only when I use version ext-4.2.1.883 but not when I use older versions.