Repeat does not work on populating 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
genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Repeat does not work on populating DataGrid

Post by genie » Thu Apr 03, 2014 4:17 pm

Good day ya all!

Need help with populating DG.

I first did...
theDataA[1]["something"]
theDataA[2]["something"]
theDataA[3]["something"]

...worked OK. But when I tried again using repeat...

This displays one record only instead of 3.

Code: Select all

   repeat with tIndex = 1 to 3
      put "WO#12345" into theDataA["& tIndex &"]["wo_num"]
      put "mm/dd/yy" into theDataA["& tIndex &"]["date"]
      put "Technician: Name" into theDataA["& tIndex &"]["technician"]
      put "Location: longitude;latitude" into theDataA["& tIndex &"]["location"]
      put "Est time: hh:mm" into theDataA["& tIndex &"]["est"]
      put "Work to do:" into theDataA["& tIndex &"]["wtd"]
      put theImageFolder & "pin.png" into theDataA["& tIndex &"]["map"]
   end repeat
Why is that? Anything wrong here?


Thanks,
Genie

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

Re: Repeat does not work on populating DataGrid

Post by Klaus » Thu Apr 03, 2014 4:23 pm

Hi Genie,

what you first did was correct, but not in the repeat loop!

Why on earth did you put QUOTES around the key numbers? 8)
This will do:

Code: Select all

 repeat with tIndex = 1 to 3
      put "WO#12345" into theDataA[tIndex]["wo_num"]
      put "mm/dd/yy" into theDataA[tIndex]["date"]
      ## etc...
Best

Klaus

genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Re: Repeat does not work on populating DataGrid

Post by genie » Thu Apr 03, 2014 4:26 pm

Klaus wrote:Hi Genie,

what you first did was correct, but not in the repeat loop!

Why on earth did you put QUOTES around the key numbers? 8)
This will do:

Code: Select all

 repeat with tIndex = 1 to 3
      put "WO#12345" into theDataA[tIndex]["wo_num"]
      put "mm/dd/yy" into theDataA[tIndex]["date"]
      ## etc...
Best

Klaus

Waaaaaaahhhhhhh! I was thinking I am appending something. LOL.

Klaus! You are the fastest person on the planet! Thank you so much!

Now, Let me give that a try...

genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Re: Repeat does not work on populating DataGrid

Post by genie » Thu Apr 03, 2014 4:36 pm

Klaus wrote:

Code: Select all

 repeat with tIndex = 1 to 3
      put "WO#12345" into theDataA[tIndex]["wo_num"]
      put "mm/dd/yy" into theDataA[tIndex]["date"]
      ## etc...
That worked! I should have asked right away... I visited my erroneous script everyday for a couple of days and :(

Thank you!


Can I ask another OT question here?

How can I get the data of the clicked row in DataGrid? I tried to get "the clickedLine", but as expected, it works on the fields that composed the row, not the row of the data grid. I realize data grid is not a field. Or at least, how do I know what line was tapped?

Regards,
Genie

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

Re: Repeat does not work on populating DataGrid

Post by Klaus » Thu Apr 03, 2014 6:13 pm

Hi Genie,

you can query -> the dgHilitedIndex of grp "your datagrid here"

Do something like htis:
...
the dgHilitedIndex of grp "your datagrid here" into tIndex
put the dgDataOfIndex[tIndex] of grp "your datagrid here" into tDataArray
## Now you have an array with the data of the currently selected row
...

Best

Klaus

genie
Posts: 108
Joined: Thu Dec 01, 2011 7:19 am

Re: Repeat does not work on populating DataGrid

Post by genie » Fri Apr 04, 2014 12:08 am

Klaus wrote:Hi Genie,

you can query -> the dgHilitedIndex of grp "your datagrid here"

Do something like htis:
...
the dgHilitedIndex of grp "your datagrid here" into tIndex
put the dgDataOfIndex[tIndex] of grp "your datagrid here" into tDataArray
## Now you have an array with the data of the currently selected row
...

Best

Klaus
Thanks for your help, Klaus.


Best Regards,
Genie

Post Reply