SMART datagrid v.1 > Examples

[ grids ver.1.3.0]   Back  Forward

Number Value  Example

1. Save Number Value in the data set

The value of the data field which Data Type is NUMBER is saved in DataSet as JavaScript Number value or undefinded. The value transferred as a string is converted and saved as Number type through parseFloat, while the value which has not been changed as Number or Nan, such as an empty string and null, is saved as undefined

Also, if minimum and maximum properties are set as a non-NaN value in the data field, they will be changed and saved within the range of these two values. (Even if the minimum and maximum properties are changed, the existing values will be maintained.) 

If the value of NUMBER field is NaN, the string to be displayed in the data cell can be specified through nanText property of the column. 

In addition, if the value of NUMBER field is NaN, you can specify the value to be saved instead through DataField.nanValue or DataSet.nanValue. (ver 1.3) In "Field1" below, nanValue is set as 1, and the others will use nanValue 0 in the data set. You can enter text value to start the test. undefined will be saved as undefined regardless of nanValue settings. 

When the user enters an empty value, if he wants to save another value rather than undefined, he can set CellEditor.emptyValue of the editor. In "Field4", 77 will be saved instead. 

Field1:Field2:Field3:Field4:
Field1.minimum:Field1.maximum:
Grid - 1
0 rows

2. Display Number Value in the data cell

You can use GridStyles.numberFormat, GridStyles.prefix and suffix to display the numeric values in the data cell more user friendly. 

Field2: numberFormat:  

Field3: prefix: Field4: suffix:  

Grid - 2
0 rows

View Source JSP 

See Also
Data Field Overview
ValueType
Integer
Number
DataField.dataType
DataField.nanValue
DataSet.nanValue
CellEditor.emptyValue
GridStyles.numberFormat
GridStyles.prefix
GridStyles.suffix
DataColumn.nanText
Examples
Boolean Value
Datetime Value
Object Field