Updating DataGrid Form coming from different Card

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
newpie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 155
Joined: Sat Jun 29, 2013 11:24 pm

Updating DataGrid Form coming from different Card

Post by newpie » Wed Feb 10, 2016 6:09 am

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.

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

Re: Updating DataGrid Form coming from different Card

Post by Klaus » Wed Feb 10, 2016 11:22 am

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

newpie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 155
Joined: Sat Jun 29, 2013 11:24 pm

Re: Updating DataGrid Form coming from different Card

Post by newpie » Wed Feb 10, 2016 3:34 pm

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

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

Re: Updating DataGrid Form coming from different Card

Post by Klaus » Wed Feb 10, 2016 3:45 pm

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.

newpie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 155
Joined: Sat Jun 29, 2013 11:24 pm

Re: Updating DataGrid Form coming from different Card

Post by newpie » Wed Feb 10, 2016 4:24 pm

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

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

Re: Updating DataGrid Form coming from different Card

Post by Klaus » Wed Feb 10, 2016 4:28 pm

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 :D

newpie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 155
Joined: Sat Jun 29, 2013 11:24 pm

Re: Updating DataGrid Form coming from different Card

Post by newpie » Wed Feb 10, 2016 4:32 pm

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?

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

Re: Updating DataGrid Form coming from different Card

Post by Klaus » Wed Feb 10, 2016 4:39 pm

Yes, that is possible!
And a good idea! :D

newpie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 155
Joined: Sat Jun 29, 2013 11:24 pm

Re: Updating DataGrid Form coming from different Card

Post by newpie » Wed Feb 10, 2016 4:49 pm

Ok, I will work on that piece and post my progress, thanks.

newpie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 155
Joined: Sat Jun 29, 2013 11:24 pm

Re: Updating DataGrid Form coming from different Card

Post by newpie » Thu Feb 11, 2016 4:40 am

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

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

Re: Updating DataGrid Form coming from different Card

Post by Klaus » Thu Feb 11, 2016 1:50 pm

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

newpie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 155
Joined: Sat Jun 29, 2013 11:24 pm

Re: Updating DataGrid Form coming from different Card

Post by newpie » Fri Feb 12, 2016 9:16 pm

Thank you Klaus, that worked great.

Post Reply