Data grid form - problem editing data [solved]

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
ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Data grid form - problem editing data [solved]

Post by ittarter » Thu Sep 28, 2017 11:48 am

Hello,

I'm trying to enter and save data in a data grid form using the field editor.

I followed the instructions in the dictionary. I'm using an array with three keys as my dgData and the data displays correctly.

However the code below (which is found in the row template script of the data grid) is malfunctioning and I don't know why.

After line 4, the handler self-aborts. I can put additional lines of code after line 4, e.g. put 1 into y, add a breakpoint, and the breakpoint isn't hit.

Code: Select all

on CloseFieldEditor pFieldEditor
put the dgIndex of me into theIndex
put the dgDataOfIndex[theIndex] of the dgControl of me into theDataA
put the text of pFieldEditor into theDataA[theIndex] of me --breakpoints after this line aren't hit... why??
set the dgDataOfIndex[theIndex] of the dgControl of me to theDataA --can't get to this line of script, so the new data can't be saved...
end CloseFieldEditor
theDataA has the correct array stored, with the values of the highlighted line of the data grid, as well as the new value, all with the correct keys.

Any insight into this unexpected behavior would be appreciated, or possibly another way to accomplish the same task.
Last edited by ittarter on Fri Sep 29, 2017 1:11 pm, edited 1 time in total.

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: Data grid form - problem editing data

Post by sritcp » Thu Sep 28, 2017 6:28 pm

Hi ittarter:

Shouldn't line 4 be

Code: Select all

put the text of pFieldEditor into theDataA
theDataA is an array containing one row of dgData[theIndex].
So, theDataA[theIndex] would point to empty, halting your handler.

Regards,
Sri

ittarter
Posts: 151
Joined: Sat Jun 13, 2015 2:13 pm

Re: Data grid form - problem editing data

Post by ittarter » Fri Sep 29, 2017 12:27 pm

sritcp wrote:Hi ittarter:

Shouldn't line 4 be

Code: Select all

put the text of pFieldEditor into theDataA
theDataA is an array containing one row of dgData[theIndex].
So, theDataA[theIndex] would point to empty, halting your handler.

Regards,
Sri
Thanks for your help, Sri.

That code didn't work (it would empty dgData completely!), but it gave me some insight into what the code was doing. I finally got it to work by specifying my key.
on CloseFieldEditor pFieldEditor
put the dgIndex of me into theIndex
put the dgDataOfIndex[theIndex] of the dgControl of me into theDataA
put the text of pFieldEditor into theDataA["Score"]
end CloseFieldEditor

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”