getDataSetByQuery formatting numeric values

Questions, tips and tricks and techniques for scripting in Servoy

getDataSetByQuery formatting numeric values

Postby ernestl » Wed Mar 25, 2015 10:39 pm

Hi

Does anyone know how to change the formatting on values returned from databaseManager.getDataSetByQuery()?
I am running the method and it is automatically formating the value to 1.4110860815E10 when it needs to return 14110860815

Or does anyone have any other suggestions on how I can resolve this?

I am using this dataSet in an html area as follows
html_area_txt = '<html>'+ds.getAsHTML()+'</html>';

Thanks
Ernest
ernestl
 
Posts: 4
Joined: Wed Mar 25, 2015 10:36 pm

Re: getDataSetByQuery formatting numeric values

Postby ROCLASI » Wed Mar 25, 2015 11:54 pm

Hi Ernest,

I see this is your first post so welcome to the forum :)

As for your question, I guess you could cast the column to a string in the SQL so JavaScript will treat it as is.

Hope this helps.
Robert Ivens
ROCLASI Software Solutions / JBS Group, Partner
SAN Developer / Servoy Valued Professional / Servoy Certified Developer
Twitter: @roclasi / @servoyforge
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5219
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: getDataSetByQuery formatting numeric values

Postby juan.cristobo » Thu Mar 26, 2015 10:09 am

If you set the format property of field to "#", you can see the right value, I think.
Juan
Madrid (Spain)

Servoy 7.4.x - MySQL / SQL Server 2008-2016
Windows 10 Pro
juan.cristobo
 
Posts: 178
Joined: Thu Apr 19, 2012 9:12 am

Re: getDataSetByQuery formatting numeric values

Postby ernestl » Thu Mar 26, 2015 8:07 pm

Thank you ROCLASI and juan.cristobo for the warm welcome and suggestions

I tried the formatting suggestion, and that did not have any effect on the field.

Changing of the sql is not an option in this case as the form is a sql testing form where the clients do not wish to cast their columns.

I noticed the ability to set html tags, would that work? if so, what tag would you suggest I modify to get this formatting to work.

Thank you
ernestl
 
Posts: 4
Joined: Wed Mar 25, 2015 10:36 pm

Re: getDataSetByQuery formatting numeric values

Postby jcompagner » Thu May 21, 2015 10:41 am

getAsHTML() does not format any values it just depends on the toString() of the various data values that are in it

the quickest way to do it right now is to query it, then walk first over your whole set formatting the columns you want to format (for every row)
and set it back
so something like

dataset.setValue(1,1, formatNumber(dataset.getValue(1,1)));
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7978
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Methods

Who is online

Users browsing this forum: Majestic-12 [Bot] and 4 guests