Formatting a currency amount in a data grid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Formatting a currency amount in a data grid
I've been successfully using the ACcontingFormat() script to format currency numbers in a normal field OK but now I have some currency values in the data that is being retrieved from my SQLite database into a data grid, so the data is a long stream of characters with each column delimited by a tab and each row delimited by a return.
Short of looping through all of the data to reformat it as a currency value, is there another way to to do this?
Thanks,
Pete
Short of looping through all of the data to reformat it as a currency value, is there another way to to do this?
Thanks,
Pete
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
With data grids there is no need to format your raw data before assigning it to the data grid. A data grid allows you to customize how the data is displayed at the time it is displayed without affecting the underlying data stored in the data grid.
Take a look at the lesson "How Do I Customize A Table's Columns?" (assuming you are using a data grid table).
In your case your custom column behavior might look something like this:
Take a look at the lesson "How Do I Customize A Table's Columns?" (assuming you are using a data grid table).
In your case your custom column behavior might look something like this:
Code: Select all
on FillInData pData
set the text of field 1 of me to AccontingFormat(pData)
end FillInData
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Once you customize a column it is up to you to set alignment, etc. You can get the current setting of the column alignment using the dgColumnAlignment property. I believe the following should work in the FillInData handler.
Alternatively you could just set the textalign of the field in your custom column group to "right" and not worry about the column alignment setting.
Code: Select all
set the textalign of field 1 of me to the dgColumnAlignment[the dgColumn of me] of me
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
The majority of the data grid has been documented in the online manual that I maintain. I don't have control over the dictionary however.
The primary data grid manual is here:
http://revolution.screenstepslive.com/s ... s/datagrid
The chapter with messages, properties and API calls are available in the API chapter of the manual (this is where you find dgColumnAlignment):
http://revolution.screenstepslive.com/s ... apters/991
There is also a tips and tricks manual. There is a link to it from the main manual (in right column) but here is the link in case you are interested.
http://revolution.screenstepslive.com/s ... agrid_tips
The primary data grid manual is here:
http://revolution.screenstepslive.com/s ... s/datagrid
The chapter with messages, properties and API calls are available in the API chapter of the manual (this is where you find dgColumnAlignment):
http://revolution.screenstepslive.com/s ... apters/991
There is also a tips and tricks manual. There is a link to it from the main manual (in right column) but here is the link in case you are interested.
http://revolution.screenstepslive.com/s ... agrid_tips
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder