DataGrid Adding Data to a Blank Cell in a Row

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
JereMiami
Posts: 127
Joined: Mon Nov 03, 2014 12:17 am

DataGrid Adding Data to a Blank Cell in a Row

Post by JereMiami » Mon Nov 03, 2014 12:30 am

DataGrid question here:

I simply want to code a button that will add data (e.g., the date & the long time) to a BLANK column in a row that has already been populated (without adding another new row (e.g., AddData)!). How on earth do I do this? Cheers! :roll:

PS: the row that the button will place the data into the columns will ALWAYS be the LAST ROW (so, the numbered row will always be different - aka the last row).

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

Re: DataGrid Adding Data to a Blank Cell in a Row

Post by Klaus » Mon Nov 03, 2014 4:53 pm

Hi Jere,

1. welcome to the forum! :D

2. Will move this thread, since this is NOT a database question, although "Datagrid" also contains "data" 8)

3. OK, herer we go...
You need to get he data from teh last line, add your data (date etc.) and write the "record" back to the datagrid.
Do like this:
a. Get the number of lines of your data in the datagrid, we cannot use the INDEX here,
because the visible last line is not neccessarily the highest INDEX of the datagrid data!
...
put the dgnumberoflines of grp "Your datagrid here..." into tNumOfLines
...
b. Get the array key and data associated with the last line:
...
put the dgdataofline[tNumOfLines] of grp "Your datagrid here..." into tArray
...
c. Now add the data you needd to the correct columns:
...
## Supposed you have these columns in your datagrid
put the data into tArray["date"]
put the time into tArray["time"]
...
d. Now write the data back into the correct line:
...
set the dgdataofline[tNumOfLines] of grp "Your datagrid here..." to tArray
...

That's it, basically :D

Get more info and the docs for datagris here:
http://lessons.runrev.com/m/datagrid



Best

Klaus

JereMiami
Posts: 127
Joined: Mon Nov 03, 2014 12:17 am

Re: DataGrid Adding Data to a Blank Cell in a Row

Post by JereMiami » Sat Nov 22, 2014 3:38 pm

Klaus,

I want to thank you so much. This worked perfectly! :D

Post Reply