Mercurial > dive4elements > river
changeset 8632:5533aa8f8b73
(issue1608) Determine field type with the first non empty element
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 26 Mar 2015 17:33:55 +0100 |
parents | b30068e92757 |
children | 8bff94ea044f |
files | gwt-client/src/main/java/org/dive4elements/river/client/client/ui/TableDataPanel.java |
diffstat | 1 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/TableDataPanel.java Thu Mar 26 17:11:36 2015 +0100 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/TableDataPanel.java Thu Mar 26 17:33:55 2015 +0100 @@ -141,7 +141,6 @@ } String[] header = list.get(0); - String[] firstValues = list.get(1); String[] displayField = new String[header.length]; ListGridField[] fields = new ListGridField[header.length]; @@ -152,16 +151,20 @@ f.setTitle(header[i]); try { - nf.parse(firstValues[i]); - f.setType(ListGridFieldType.FLOAT); + /* Try to determine the type with the first + * non empty element. */ + for (int j = 1; j < list.size(); j++) { + if (!list.get(j)[i].isEmpty()) { + nf.parse(list.get(j)[i]); + f.setType(ListGridFieldType.FLOAT); + break; + } + } } catch (NumberFormatException nfe) { f.setType(ListGridFieldType.TEXT); } - // TODO Numerical sorting still does not work if the first values are empty (then - // it defaults to TEXT, currently. Shall be fixed. - // To keep server-side formatting and i18n also of // float values, we will store the value once formatted 'as is' // to be displayed and once as e.g. float to allow functions like