Page 1 of 1

Define Datagrid Form Columns

Posted: Tue Nov 08, 2016 6:49 pm
by Batninja
Hi, hope someone can help me on this please.

I can't see how the columns used in a Datagrid Form are defined. In the tutorial "Creating a list of people" the datagrid behaviour script FillInData uses values from columns pDataArray["LastName"], pDataArray["FirstName"], pDataArray["Title"] and pDataArray["Image URL"], which works fine when I follow the exercise.
e.g.
set the text of field "Name" of me to pDataArray["LastName"] & comma & space & pDataArray["FirstName"]
set the text of field "Title" of me to pDataArray["Title"]
set the filename of image "image" of me to pDataArray["Image URL"]

But if I create a new Datagrid Form the columns seem to be setup automatically as "label 1", "label 2", "label 3"which I found just by guessing!

i.e. this code in a new Datagrid Form behaviour script works fine:
set the text of field "Width" of me to pDataArray["label 1"]
set the text of field "Height" of me to pDataArray["label 2"]
set the text of field "Name" of me to pDataArray["label 3"]

But where does label 1 etc come from? In a data grid table then they are setup in the properties but when you choose a Datagrid Form the columns tab disappears. I haven't setup label 2 or label 3, are they the defaults in the pDataArray variable?

Any help or suggestions gratefully received on to how to specify the column headers in a Datagrid Form?

Roger

Re: Define Datagrid Form Columns

Posted: Tue Nov 08, 2016 7:12 pm
by Klaus
Hi Roger,

how are you creating the ARRAY used to fill in the data?
They must be created somewhere and at some pont and that's the time where the names of the keys are defined! :D


Best

Klaus

Re: Define Datagrid Form Columns

Posted: Tue Nov 08, 2016 9:48 pm
by Batninja
Thanks Klaus

I started to think it must be something to do with the pDataArray array variable. But I did not create it, just added a Datagrid to my card and set it as a form.

Presumerably the array is set by default. Does this mean I just need to modify the pDataArray?

THanks for your assistance so far!

Re: Define Datagrid Form Columns

Posted: Wed Nov 09, 2016 12:52 pm
by Klaus
OK, but how do you get whatever data into your datagrid?

There is nothing that could happen automatically this way,
there must be s script involved somehow at some point! 8)

Re: Define Datagrid Form Columns

Posted: Wed Nov 09, 2016 1:14 pm
by Batninja
Ok I think I have solved it!

If you:

1. Add a datagrid control(by default it is a table)
2. Change to a Form
3. Edit Behaviour script - then the columns headers are named label 1, label 2, label 3 - etc.

However if you:
1. Add a datagrid control (by default it is a table)
2. Configure columns in the table (e.g. naming them Width, Height and Name)
3. Change to a Form
Then the behaviour script and pDataArray uses the columns names assigned in the original datagrid table

i.e. this code works in the behavior script:

Code: Select all

on FillInData pDataArray
   set the text of field "Height" of me to pDataArray["Height"]
   set the text of field "Name" of me to pDataArray["Name"]
end FillInData
Thanks for your input, just writing it down and getting feedback helps to make it clearer.

Re: Define Datagrid Form Columns

Posted: Thu Nov 10, 2016 11:44 pm
by SparkOut
Why a day? Clearly a spammer, even without today's evidence

Re: Define Datagrid Form Columns

Posted: Fri Nov 11, 2016 10:49 am
by Klaus
I am a generous guy, you know, but whom ecxactly are you talking about? :D

Re: Define Datagrid Form Columns

Posted: Fri Nov 11, 2016 7:22 pm
by SparkOut
Him, over there behind that pile of distraction

Re: Define Datagrid Form Columns

Posted: Fri Nov 11, 2016 7:30 pm
by Klaus
Ah, I see!
Not! :D