Example code to populate a datagrid one line at a time

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
panosdk
Posts: 14
Joined: Mon Jul 22, 2013 10:34 am

Example code to populate a datagrid one line at a time

Post by panosdk » Tue Dec 29, 2015 12:26 pm

I want to press a button from card1 and add 1 entry (just text) into 3 columns on card2. I know how to write entries on the datagrid but i dont know how to add one, one at a time. If anyone has the time, plz write a simple example.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Example code to populate a datagrid one line at a time

Post by dunbarx » Tue Dec 29, 2015 2:58 pm

I always do this in the clear, extracting the contents of a dataGrid, manipulating that data, and restoring. It is possible to do this within the DG itself, I just don't.

Code: Select all

get the dgText of group "yourDataGrid"
put return & "AA" & tab & "BB" & tab & "CC" after it
set the dgText of group "yourDataGrid to it
That sort of thing. This will place that new text in the first three columns of a new row. I find doing it this way is easier for me, since I have complete control, via chunk expressions, of the process.

Craig Newman

panosdk
Posts: 14
Joined: Mon Jul 22, 2013 10:34 am

Re: Example code to populate a datagrid one line at a time

Post by panosdk » Tue Dec 29, 2015 3:10 pm

Yes thats it. Thank you. And one last question. How do i clear the whole datagrid?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Example code to populate a datagrid one line at a time

Post by dunbarx » Tue Dec 29, 2015 5:20 pm

Hi.

Same sort of methodology, except you do not need to move data out of the DG itself

Code: Select all

set the dgData of group "yourDataGrid" to ""
or
set the dgText of group "yourDataGrid" to "" 
Craig

Post Reply