Can't get data from a Data Grid

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

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Can't get data from a Data Grid

Post by bogs » Sat Oct 05, 2019 7:27 pm

dunbarx wrote:
Sat Oct 05, 2019 5:37 pm
Someone please remind us both where the "alternate" dictionary is. I am not at my normal computer, and do not have the URL here.
Assuming you didn't mean Tiny Dictionary (which Klaus helpfully linked too, and is the quickest I know of), I'm thinking you might be looking for Milby's online one here, or alternately, Max's excellent wiki version here which is super-duper quick and includes not only the examples found in the dictionary, but personal examples like the old comments section used to hold.
MichaelBluejay wrote:
Sat Oct 05, 2019 6:54 pm
I was being frustrated. When I'm pointed to an article as though it answers my question, when it doesn't in fact answer my question, then I'm afraid I can't see that as helpful.
I can understand frustration, and I'm sorry if you feel I contributed to yours, however, I wasn't pointing to that article "as though it answers my (your) question", I was in fact asking if that held what you were asking about for clarity, which is why there is a question mark at the end of the sentence and before the link.
bogs wrote: Hmmmmm.... you mean this?
Although that section talks about behavior scripts, I am pretty sure the sections referred to *are* in fact the way you'd go after the information. However, I am no DG expert, and certainly defer to others when my own assumptions are incorrect. In this case, I was looking for clarity into what exactly you were trying to get to. I'm glad Klaus could answer it for you.
Image

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Can't get data from a Data Grid

Post by Klaus » Sat Oct 05, 2019 8:09 pm

bogs wrote:
Sat Oct 05, 2019 7:27 pm
Although that section talks about behavior scripts, I am pretty sure the sections referred to *are* in fact the way you'd go after the information. However, I am no DG expert, and certainly defer to others when my own assumptions are incorrect.
That lesson unfortunately only deals with getting the content of one specific column.
As I said this functionality is not supplied by the datagridlibrary, but could easily be added. :-)

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Can't get data from a Data Grid

Post by bogs » Sat Oct 05, 2019 8:26 pm

Klaus wrote:
Sat Oct 05, 2019 8:09 pm
That lesson unfortunately only deals with getting the content of one specific column.
So it wouldn't be possible to loop through to split each column out to its own array, one at a time? I'll tinker while waiting heh.
Image

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Can't get data from a Data Grid

Post by Klaus » Sat Oct 05, 2019 9:35 pm

bogs wrote:
Sat Oct 05, 2019 8:26 pm
Klaus wrote:
Sat Oct 05, 2019 8:09 pm
That lesson unfortunately only deals with getting the content of one specific column.
So it wouldn't be possible to loop through to split each column out to its own array, one at a time? I'll tinker while waiting heh.
https://forums.livecode.com/viewtopic.p ... 81#p183963 8)

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Can't get data from a Data Grid

Post by bogs » Sat Oct 05, 2019 9:59 pm

LOL! DOH :oops:
Image

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Can't get data from a Data Grid

Post by SparkOut » Sat Oct 05, 2019 10:09 pm

If you want to sum a column to get the aggregate value, it's not one line but pretty lean:
http://lessons.livecode.com/m/datagrid/ ... or-columns

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Can't get data from a Data Grid

Post by Klaus » Sat Oct 05, 2019 10:54 pm

Hi Sparkout,

ah, yes, or this way. :-)

@Michael
Here a little script that you can put into your datagrid group directly (NOT the behaviour, just the script of that group):

Code: Select all

getprop dgDataOfColumns [tUserSelectedColumns]
   put the dgdata of me into sDataArray
   ## We build an CR delimited list of all entries in your columns
   repeat for each key tKey in sDataArray
      put sDataArray[tKey][tUserSelectedColumns] & CR after tTempColumns
   end repeat
   delete char -1 of tTempColumns
   return tTempColumns
end dgDataOfColumns
Then use it like this in your other scripts:

Code: Select all

...
put the dgDataOfColumns["name of your desired column here..."] of grp "ledger" into fld "display of all my beloved colums as CR delimited text"
## :-)
...
Best

Klaus

P.S.
As we can see, if LC might lack of some functionality, we add this in most cases, as long as no engine changes are required.
We can script almost everything, love it! :D

MichaelBluejay
Posts: 222
Joined: Thu Jul 01, 2010 11:50 am

Re: Can't get data from a Data Grid

Post by MichaelBluejay » Sun Oct 06, 2019 9:50 am

bogs, I'm sorry I misunderstood you.

Thank you everyone for your help. I would be literally unable to complete my development without the awesome help available on this forum.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Can't get data from a Data Grid

Post by bogs » Sun Oct 06, 2019 10:46 am

's no problem :D

People are hard enough to understand most times, even in person where you have visual clues and inflections of voice to aid in determining what they mean, in text it is always a lot harder and as I have mentioned in other posts, I know my style of writing is not possibly the best around for clarity :wink:
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7228
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Can't get data from a Data Grid

Post by jacque » Sun Oct 06, 2019 5:45 pm

MichaelBluejay wrote:
Sat Oct 05, 2019 9:53 am
I don't suppose there's a command to get all the data for a particular column (all the rows), as either a list or an array? I looked but couldn't find one.

I know I can do the dgtext of grp "nameOfTheDataGrid" to get the whole table of data and then loop through it, but the LiveCode company goes on and on about how LiveCode requires less code than other languages, so I'd like less code here, please.
You can get the dgtext, then split it by column. Each key of the resulting array is the content of a column.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Zryip TheSlug
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 163
Joined: Tue Jan 26, 2010 10:15 pm
Contact:

Re: Can't get data from a Data Grid

Post by Zryip TheSlug » Sat Oct 12, 2019 5:42 pm

Hi Michael,

Note the DataGrid Helper plugin is capable of applying various Grand Total functions to a DataGrid

http://lessons.livecode.com/m/4068/l/85 ... l-function
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”