Philosophical DataGrid Questions

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Philosophical DataGrid Questions

Post by lohill » Thu Feb 04, 2010 7:50 pm

I am using a dataGrid with 16 columns and the number of rows will probably not exceed 30. Many of the columns have numbers in them that can be positive or negative and some of those I need to show either two or four decimal places. I am currently using the special button 'My Default Column Behavior' as suggested in Trevor's tutorial http://revolution.screenstepslive.com/s ... to-a-Cell- to make the negative numbers show up in red and the positive numbers to show up in green.

In order to make the numbers have a fixed number of decimal places I could insert code similar to the following in each of the Case statements of that button script to get the format I want:

Code: Select all

    ...     
set the numberFormat to "#.00"  -- or #.0000 as the case requires
put pData * 1 into pData
    ...  
Is this an efficient way to handle the number formatting?

A second question goes back even further. Since I have at least 10 columns that require special formatting, is the switch - case technique in the single button 'My Default Column Behavior' as efficient as having individual scripts (buttons) that the Column Inspector would give.

Finally, I have been avoiding any type of currency formatting in the columns because I need to add them up. I would prefer to have that formatting in US currency however if there is a good way to handle it. Any suggestions?

Regards and thanks,
Larry

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Re: Philosophical DataGrid Questions

Post by trevordevore » Fri Feb 05, 2010 3:45 pm

I have been avoiding any type of currency formatting in the columns because I need to add them up
Keep the data as integers in the actual Data Grid data but format them for display (as currency) in the FillInData handler.
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

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: Philosophical DataGrid Questions

Post by lohill » Fri Feb 05, 2010 6:43 pm

Trevor,
Keep the data as integers in the actual Data Grid data but format them for display (as currency) in the FillInData handler.
That is great. I had been assuming all along that if I expressed every thing as currency that I would just have to remove all the commas and dollar signs before calculations. I should have tried it earlier and just looked at what I had in dgText. I must say your DataGrid is a wonderful invention.

Larry

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Re: Philosophical DataGrid Questions

Post by trevordevore » Fri Feb 05, 2010 7:22 pm

Thanks Larry. As for your efficiency question - I would be surprised if you saw much of a performance hit. Personally I would keep a single script with the switch statement rather than managing multiple scripts.
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

Post Reply