Page 2 of 2

Re: Can't get data from a Data Grid

Posted: Sat Oct 05, 2019 7:27 pm
by bogs
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.

Re: Can't get data from a Data Grid

Posted: Sat Oct 05, 2019 8:09 pm
by Klaus
bogs wrote: Sat Oct 05, 2019 7:27 pmAlthough 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. :-)

Re: Can't get data from a Data Grid

Posted: Sat Oct 05, 2019 8:26 pm
by bogs
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.

Re: Can't get data from a Data Grid

Posted: Sat Oct 05, 2019 9:35 pm
by Klaus
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)

Re: Can't get data from a Data Grid

Posted: Sat Oct 05, 2019 9:59 pm
by bogs
LOL! DOH :oops:

Re: Can't get data from a Data Grid

Posted: Sat Oct 05, 2019 10:09 pm
by SparkOut
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

Re: Can't get data from a Data Grid

Posted: Sat Oct 05, 2019 10:54 pm
by Klaus
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

Re: Can't get data from a Data Grid

Posted: Sun Oct 06, 2019 9:50 am
by MichaelBluejay
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.

Re: Can't get data from a Data Grid

Posted: Sun Oct 06, 2019 10:46 am
by bogs
'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:

Re: Can't get data from a Data Grid

Posted: Sun Oct 06, 2019 5:45 pm
by jacque
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.

Re: Can't get data from a Data Grid

Posted: Sat Oct 12, 2019 5:42 pm
by Zryip TheSlug
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