Add Data to a 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

Post Reply
tegwin
Posts: 21
Joined: Mon Dec 16, 2013 3:41 am

Add Data to a Grid

Post by tegwin » Wed Dec 18, 2013 10:16 pm

Hello,
I am trying to add data to a data grid.

I have this code

Code: Select all

on mouseUp
       put databaseGetContactDetails() into field "contact details"
   put databaseGetContactDetails() into "Data Grid 1"
   
    
end mouseUp


function databaseGetContactDetails
    ## Query the database for contact details to be displayed in the field
    put getDatabaseID() into tDatabaseID
    put "SELECT * from contact_details" into tSQL
    put revDataFromQuery(tab,return,tDatabaseID,tSQL) into tRecords
    return tRecords
end databaseGetContactDetails
But it does work in the data grid. What am I doing wrong here

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Add Data to a Grid

Post by Klaus » Wed Dec 18, 2013 10:26 pm

Hi tegwin,

Code: Select all

on mouseUp
   put databaseGetContactDetails() into field "contact details"

   # Wrong syntax!
   ###put databaseGetContactDetails() into "Data Grid 1"

  ## A Datagrid is a group and you need to set its DGTEXT property!
  set the dgtext of grp "Data Grid 1" to databaseGetContactDetails()
end mouseUp
Best

Klaus

tegwin
Posts: 21
Joined: Mon Dec 16, 2013 3:41 am

Re: Add Data to a Grid

Post by tegwin » Wed Dec 18, 2013 10:58 pm

Perfect thank you very much

tegwin
Posts: 21
Joined: Mon Dec 16, 2013 3:41 am

Re: Add Data to a Grid

Post by tegwin » Wed Dec 18, 2013 11:01 pm

Ok I have just tried this and I get the following error


button "Get Data": execution error at line 3 (Chunk: can't find background), char 16

Not sure what that means

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Add Data to a Grid

Post by Klaus » Wed Dec 18, 2013 11:08 pm

I supposed that "Data Grid 1" is the name of your datagrid!?
If it isn't, replace it with the name of YOUR datagrid and it should work 8)

tegwin
Posts: 21
Joined: Mon Dec 16, 2013 3:41 am

Re: Add Data to a Grid

Post by tegwin » Thu Dec 19, 2013 12:12 am

Nope that is not the case. i have checked the name and its the same. I have renamed my datagrid to DG for simplicity and changed

Data Grid 1 to DG in the code and still same error

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

Re: Add Data to a Grid

Post by dunbarx » Thu Dec 19, 2013 2:45 am

Hi.

What happens if, from msg, you ask: answer there is a group "DG"

Craig Newman

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Add Data to a Grid

Post by Klaus » Thu Dec 19, 2013 12:47 pm

Hi tegwin,

maybe you should first work through these stack to get the very basics of Livecode:
http://www.hyperactivesw.com/revscriptc ... ences.html


Best

Klaus

Post Reply