format datagrid values with function
Posted: Tue May 05, 2015 10:50 pm
Hi Guys,
I have the following sql statement below which works OK. However I've written a function called returnCurrency which adds currency symbol, decimal, commas for every thousand, two digits to indicate pence etc to a whole number and I want to wrap this function around my fields item_price and line_price. As I'm populating a datagrid using "set the dgText", I'm not quite sure how to achieve this - can someone give me some pointers. My initial thoughts were to convert the item values before I use the set dgText (as you can see, ive commented them out as they were not working), but that didn't work as it populated the column with data formatted incorrectly, perhaps it was the comma that threw out the formatting...
I have the following sql statement below which works OK. However I've written a function called returnCurrency which adds currency symbol, decimal, commas for every thousand, two digits to indicate pence etc to a whole number and I want to wrap this function around my fields item_price and line_price. As I'm populating a datagrid using "set the dgText", I'm not quite sure how to achieve this - can someone give me some pointers. My initial thoughts were to convert the item values before I use the set dgText (as you can see, ive commented them out as they were not working), but that didn't work as it populated the column with data formatted incorrectly, perhaps it was the comma that threw out the formatting...
Code: Select all
put "SELECT material, item_price, qty, line_price, lineID FROM project_material WHERE projectID =" && "'" & tProjectID & "'" & "ORDER BY lineID" into tTheSQLQuery
put revDataFromQuery(tab, cr, gConnID, tTheSQLQuery) into tTheData
if tTheData begins with "revdberr," then
delete item 1 of tTheData
else
--put returnCurrency(item 2 of tTheData) into item 2 of tTheData
--put returnCurrency(item 4 of tTheData) into item 4 of tTheData
set the dgText[true] of me to "material" & tab & "item_price" & tab & "qty" & tab & "line_price" & tab & "lineID" & cr & tTheData
end if