How to insert a data in a data grid from other substack

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
lemodizon
Posts: 175
Joined: Thu Apr 05, 2018 3:33 pm

How to insert a data in a data grid from other substack

Post by lemodizon » Thu Feb 28, 2019 2:51 pm

hello everyone i just want to ask what is the script if i want to transfer the data from the fields in my substack to the main stack of the datagrid. thanks in advance :D
Attachments
datagrid.PNG
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9644
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: How to insert a data in a data grid from other substack

Post by dunbarx » Thu Feb 28, 2019 2:56 pm

Hi.

You can collect the entirety of the contents of a DG using either the "dgData" or the "dgText". This gives either an array or a tab/return delimited dataSet.

Going the other way, if you format your field data with tabs and returns, just as if you wanted to paste into an Excel spreadsheet, and set the "dgData" of the dataGrid to that dataSet, the information will appear by magic.

Craig Newman

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

Re: How to insert a data in a data grid from other substack

Post by Klaus » Thu Feb 28, 2019 3:59 pm

Hi Lemuel,

looks like you have a datagrid of typ TABLE, right?
Then you can modify -> the dgtext of grp "your datagrid here"
which is nothing but TAB and CR delimited text!
Do this, you may need to add -> of cd XYZ of stack XZY in the script,
depending where you put the script:

Code: Select all

...
## Collect the data in stack "Substack"
put fld "ID Number" & TAB & fld "Real Name" & TAB & fld "AGE" into tNewData

## Check if datagrid already has content:
put the dgtext of grp "your datagrid here" into tOldData

## New and first entry:
if tOldData = EMPTY then
  put tNewData into tOldData
else
  ## We ADD the data
  put CR & tNewData after tOldData
end if
## Now set the new data:
set the dgtext of grp "your datagrid here" to tOldData
...
Best

Klaus

lemodizon
Posts: 175
Joined: Thu Apr 05, 2018 3:33 pm

Re: How to insert a data in a data grid from other substack

Post by lemodizon » Tue Mar 05, 2019 4:53 am

Hello Klaus,

I tried your code there is error i think i did something wrong or i missed a script.
where will i put this: of cd XYZ of stack XZY in the script,
depending where you put the script:

Thanks Klaus
Attachments
Capture.PNG
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

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

Re: How to insert a data in a data grid from other substack

Post by Klaus » Tue Mar 05, 2019 10:56 am

What is the exact "address" of the datagrid?
LC needs to know, just like the postman! 8)
...
put the dgtext of grp "your datagrid here" OF CD "xyz" OF STACK "your stack here" into tOldData
...

lemodizon
Posts: 175
Joined: Thu Apr 05, 2018 3:33 pm

Re: How to insert a data in a data grid from other substack

Post by lemodizon » Thu Mar 07, 2019 9:51 am

Klaus,
Thanks again this is now working. here is the script i created. :)
Capture11.PNG
Thank you & God Bless Everyone :wink:

Regards,
lemodizon

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”