format data before setting the datagrid

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

format data before setting the datagrid

Post by jalz » Wed Oct 14, 2015 10:51 pm

Hi Guys,

I have a sql query which populates a variable called tTheData with about 5 fields from my SQLite database. I then use the following command to populate the datagrid with the data thats been returned.

set the dgText of group "myDataGrid" to tTheData

This all worked great, however Item 3 of each row in tTheData is a date field and I now need to store this in YYYY-MM-DD in a text field in my database so I can query against it fairly reliably. The problem is, I don't want it to display like that on my dg on my user interface, so I wrote a function called sqlToDMY which converts it to the display format I want to see it in. Question is, what is the best way to get the third row of data wrapped around my function, logic suggests a use a loop to go through tTheData and rewrite the 3 field and the set the dg, but which loop and is there an easier way?

Many thanks as always

Jalz

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: format data before setting the datagrid

Post by dunbarx » Thu Oct 15, 2015 2:26 pm

Hi.

Always best to format DG stuff is in the clear. So, yes, change tTheData using chunk and delimiter tools, and then load into the dataGrid.

Craig Newman

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: format data before setting the datagrid

Post by Klaus » Thu Oct 15, 2015 3:12 pm

You could add a custom behaviour to that namely column and script a "fillindata" handler for that,
but looping through the data first seems to be a lot more straightforward and easier! :D

Post Reply