Datagrid dgHilitedLines of group is blank

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
cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Datagrid dgHilitedLines of group is blank

Post by cusingerBUSCw5N » Fri Nov 17, 2017 5:08 am

I have been in Datagrid hell all day. :cry: I have a series of datagrids that are bringing in information from a url(turl) call. The information is loading properly. I want the user to be able to select an item in the datagrid (a button) and then do something with it. The problem is that many of the buttons inside the datagrid don't recognize script asking for the dghilitedlines of the group - and return a blank, rather than the data.

I thought something might be corrupt, so I deleted my preferences file, switched to Indy 7.1.7, tried it on new cards, and even started a new stack. The datagrid on the new stack fails as well. Some of the datagrids with the same code work on my original stack. However, I am attaching the stack with only one datagrid on it that is failing for me (ie. when you click on the button inside the datagrid, it returns empty, instead of giving me the data for that line.)

The script loading the info takes tresult and does this:

Code: Select all

split tresult by RETURN
      repeat with x=1 to tnum
            set the itemdelimiter to TAB
          split tresult[x] by TAB 
          put tresult[x][1] into theDataB[x]["bizname_facebook2"]

          //put tresult[x][2] into theDataB[x]["facebook2"]
 end repeat


set the dgData of group "datagrid_facebook" to theDataB

The datagrid's script is:

[code]put pDataArray["bizname_facebook2"] into tuse
   answer tuse & " in datagrid"
   set the label of button "bizname_facebook" of me to tuse
Here is the script for the buttons:

Code: Select all

       put the dgHilitedLines of group "datagrid_facebook" into theLine  --grabs hilited line

     put the dgDataOfLine[theLine] of group "datagrid_facebook" into theDataA
     -- theDataA is now an array variable.
     -- then you get the specific column values by using the column names
     put theDataA["bizname_facebook2"] into tuse
     answer tuse
It is supposed to give me the name on the button

I have been messing around with this for 10 hours.... and am at a complete loss. Any help out there? I am on Windows 10 with Indy 7.1.7 Thank you

I should also say that earlier, i tried turning my computer off and then on again...and the datagrid worked (meaning that the button returned the information that was requested). But then it quickly went back into failure mode.
Attachments
datagridproblem.zip
(5.16 KiB) Downloaded 156 times

Curry
Posts: 111
Joined: Mon Oct 15, 2007 11:34 pm
Location: USA
Contact:

Re: Datagrid dgHilitedLines of group is blank

Post by Curry » Fri Nov 17, 2017 5:49 am

The dgHilitedLines was empty, so theDataA also empty.

Turning on row autohilite for the datagrid, it works.

(But datagrids are not always the easiest solution for some tasks.)
Best wishes,

Curry Kenworthy

LiveCode Development, Training & Consulting
http://livecodeconsulting.com/

WordLib: Conquer MS Word & OpenOffice
SpreadLib: "Excel-lent" spreadsheet import/export
http://livecodeaddons.com/

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Datagrid dgHilitedLines of group is blank

Post by MaxV » Fri Dec 01, 2017 2:10 pm

Your code needs repeat, ans the group name is not welcomed to livecode (I don't know why), so this code works:

########CODE to copy and paste#######
on MouseUp
put the dgHilitedLines of group "temp1" into theLine --grabs hilited line
answer theLine
repeat for each item tItem in theLine
put the dgDataOfLine[tItem] of group "temp1" into theDataA
-- theDataA is now an array variable.
-- then you get the specific column values by using the column names
put theDataA["col 1"] & return after tuse
end repeat
answer tuse
end MouseUP
#####END OF CODE generated by http://tinyurl.com/j8xf3xq with livecode 9.0.0-dp-10#####
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”