Page 1 of 1

Add Data to a Grid

Posted: Wed Dec 18, 2013 10:16 pm
by tegwin
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

Re: Add Data to a Grid

Posted: Wed Dec 18, 2013 10:26 pm
by Klaus
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

Re: Add Data to a Grid

Posted: Wed Dec 18, 2013 10:58 pm
by tegwin
Perfect thank you very much

Re: Add Data to a Grid

Posted: Wed Dec 18, 2013 11:01 pm
by tegwin
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

Re: Add Data to a Grid

Posted: Wed Dec 18, 2013 11:08 pm
by Klaus
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)

Re: Add Data to a Grid

Posted: Thu Dec 19, 2013 12:12 am
by tegwin
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

Re: Add Data to a Grid

Posted: Thu Dec 19, 2013 2:45 am
by dunbarx
Hi.

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

Craig Newman

Re: Add Data to a Grid

Posted: Thu Dec 19, 2013 12:47 pm
by Klaus
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