Page 1 of 1
Updating DataGrid Form coming from different Card
Posted: Wed Feb 10, 2016 6:09 am
by newpie
Hello, I researched my issue and found this post
http://forums.livecode.com/viewtopic.ph ... 48&p=96560, but it seems my data is still not working. Here is the situation:
Background Data: I am sending my datagrid form data to another card for updating with code as so:
Code: Select all
put theDataA["var1"] into fld "var1Field" of cd "AnotherCardd"
put the dgnumberoflines of grp "myDataGridForm" into tlastLine
put tlastLine into fld "dataGridRecord" of cd "AnotherCard"
put the dgdata of group "myDataGridForm" into fld "dataGridGroup" of cd "AnotherCard"
go to cd "AnotherCard"
Then I edit the information in "AnotherCard" and submit with this code:
Code: Select all
put field "dataGridGroup" into tDataGridGroup
put field "dataGridRecord" into tDataGridNumber
put field "var1Field" into tDataGridGroup[tDataGridNumber]["var1"]
set the dgdata of group "myDataGridForm" of cd "dataGridCard" to tDataGridGroup
go to card "dataGridCard"
Issue:
When I go to "dataGridCard" it only shows the last record edited on the top. I tried putting a "1" in for the tDatagridNumber, but not dice still.
I am hoping I am missing something easy to make this work.
Thank you for any help.
Re: Updating DataGrid Form coming from different Card
Posted: Wed Feb 10, 2016 11:22 am
by Klaus
Hi newpie,
Code: Select all
...
put the dgdata of group "myDataGridForm" into fld "dataGridGroup" of cd "AnotherCard"
...
"the dgdata of grp XYZ" is an ARRAY, so you cannot simply put it into a field!
Try with "the dgtext of grp XYZ".
Best
Klaus
Re: Updating DataGrid Form coming from different Card
Posted: Wed Feb 10, 2016 3:34 pm
by newpie
Hey Klaus just so I get this correct. Is this what you suggest:
DataGrid Card:
Code: Select all
put theDataA["var1"] into fld "var1Field" of cd "AnotherCardd"
put the dgnumberoflines of grp "myDataGridForm" into tlastLine
put tlastLine into fld "dataGridRecord" of cd "AnotherCard"
put the dgtext of group "myDataGridForm" into fld "dataGridGroup" of cd "AnotherCard"
go to cd "AnotherCard"
Edit/New Card:
Code: Select all
put field "dataGridGroup" into tDataGridGroup
put field "dataGridRecord" into tDataGridNumber
put field "var1Field" into tDataGridGroup[tDataGridNumber]["var1"]
set the dgtext of group "myDataGridForm" of cd "dataGridCard" to tDataGridGroup
Thanks
Re: Updating DataGrid Form coming from different Card
Posted: Wed Feb 10, 2016 3:45 pm
by Klaus
Yes, that is what I meant. But I do not know if this works the way you exspect, since I can only see and comment the syntax.
Re: Updating DataGrid Form coming from different Card
Posted: Wed Feb 10, 2016 4:24 pm
by newpie
Thanks for the quick response. I thought that is what you suggested. Basically it returns a blank screen. I can see from test that the full datagrid is not being transferred over. I will try to play with some more or have to give up this putting datagrid in different card and try my best to do all edits from the actual datagrid card.
I will post my progress later on this technique.
Thanks
Re: Updating DataGrid Form coming from different Card
Posted: Wed Feb 10, 2016 4:28 pm
by Klaus
Yes, that is what I suggested, since you cannot put any array into a field without looping
through its keys and turn the array into a e.g. TAB and CR delimited text list.
but since I only see your syntax and not your stack and everything I cannot do more than
do osme guessing from the syntax

Re: Updating DataGrid Form coming from different Card
Posted: Wed Feb 10, 2016 4:32 pm
by newpie
Ok, I had a quick question. As I can't put the array in a field. Can I put the array in a custom property instead and use this to transfer back to the original datagrid card from the edit/new card?
Re: Updating DataGrid Form coming from different Card
Posted: Wed Feb 10, 2016 4:39 pm
by Klaus
Yes, that is possible!
And a good idea!

Re: Updating DataGrid Form coming from different Card
Posted: Wed Feb 10, 2016 4:49 pm
by newpie
Ok, I will work on that piece and post my progress, thanks.
Re: Updating DataGrid Form coming from different Card
Posted: Thu Feb 11, 2016 4:40 am
by newpie
Hey Klaus, I tried this out, but having little trouble. Is there anything off with the below as it still get my original problem. The last entry only shows on the datagrid form when I am done editing.
DataGrid Card:
Code: Select all
Code: Select all
put theDataA["var1"] into fld "var1Field" of cd "AnotherCardd"
put the dgnumberoflines of grp "myDataGridForm" into tlastLine
put tlastLine into fld "dataGridRecord" of cd "AnotherCard"
put the dgdata of grp "myDataGridForm" into tDatagridVar
set the customKeys["cDataGridArray"] to tDatagridVar
go to cd "AnotherCard"
Edit/New Card:
Code: Select all
Code: Select all
put the customKeys["cDataGridArray"] of the stack "details" into tDataGridGroup
put field "dataGridRecord" into tDataGridNumber
put field "var1Field" into tDataGridGroup[tDataGridNumber]["var1"]
set the dgdata of group "myDataGridForm" of cd "dataGridCard" to tDataGridGroup
Thanks for the help
Re: Updating DataGrid Form coming from different Card
Posted: Thu Feb 11, 2016 1:50 pm
by Klaus
Hi newpie,
when accessing custom properties you always need to add the address = name of object which holds the custom property!
newpie wrote:
Code: Select all
...
### put the dgdata of grp "myDataGridForm" into tDatagridVar
### set the customKeys["cDataGridArray"] to tDatagridVar
## Check CUSTOMKEYS in the dictionary!
set the cDataGridArray OF THIS STACK to the dgdata of grp "myDataGridForm"
go to cd "AnotherCard"
...
Edit/New Card:
Code: Select all
...
### put the customKeys["cDataGridArray"] of the stack "details" into tDataGridGroup
put the cDataGridArray of stack "details" into tDataGridGroup
## or "...of THIS stack", but NOT "...of THE stack XYZ"
put field "dataGridRecord" into tDataGridNumber
put field "var1Field" into tDataGridGroup[tDataGridNumber]["var1"]
set the dgdata of group "myDataGridForm" of cd "dataGridCard" to tDataGridGroup
Best
Klaus
Re: Updating DataGrid Form coming from different Card
Posted: Fri Feb 12, 2016 9:16 pm
by newpie
Thank you Klaus, that worked great.