Data Grid issue after deleting rows

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
mrk
Posts: 21
Joined: Mon Apr 03, 2017 6:16 am
Location: Perth, Western Australia

Data Grid issue after deleting rows

Post by mrk » Fri Aug 11, 2017 3:18 pm

Hi all

Finally starting to get my head into how Livecode works.....but I'm having an issue now that has me quite stuck.
I have one DataGrid (DG1) where I list available equipment. When the user double clicks on a selected piece of equipment, it gets added to another DataGrid (DG2).
Eventually the Information in DG2 will be submitted to a MYSQL table. However, in the mean time, if a user accidently adds a piece of equipment from DG1 to DG2 they need to remove it from DG2. To remove the equipment from DG2, they double click the unwanted equipment. I am able to remove the unwanted equipment, but if I remove all equipment, the following error is generated every time I go to add equipment again. "An error has occurred in behaviour for the column template: Chunk: no such object"
If I close LC down and restart, everything works okay. I can replicate this every time. Please see ScriptError1.jpg for a screenshot of the script.
To delete the unwanted rows (Equipment) from DG2 I use the following code (found this in another post...), I want the user to double click the item rather than having to highlight, then click a "Delete" button :
on mouseDoubleDown
put the dgHilitedIndex of me into theIndex
DeleteIndex theIndex
end mouseDoubleDown

Thanks in advance.
Attachments
ScriptError1.jpg

mrk
Posts: 21
Joined: Mon Apr 03, 2017 6:16 am
Location: Perth, Western Australia

Re: Data Grid issue after deleting rows

Post by mrk » Fri Aug 11, 2017 3:32 pm

Update
tried the following with the same results

put the dgHilitedLines of group "dgSelectedEquip" into theLineNo
dispatch "deleteline" to group "dgSelectedEquip" with theLineNo

However one thing I did try was add the following code a "Close don't Save" button:
on mouseUp
set the dgData of group "dgSelectedEquip" to empty
close this stack
end mouseUp

this clears the DG of all rows and doesn't cause the error.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Data Grid issue after deleting rows

Post by Klaus » Fri Aug 11, 2017 3:35 pm

Hi mrk,

just made a quick test here with both of your scripts and it works as exspected, even when deleting the last row?


Best

Klaus

mrk
Posts: 21
Joined: Mon Apr 03, 2017 6:16 am
Location: Perth, Western Australia

Re: Data Grid issue after deleting rows

Post by mrk » Fri Aug 11, 2017 3:47 pm

Klaus

Thanks for the prompt response. I was worried that may have been a response :-(
Well, it shows that the codes works.....I must have done something during my "testing/learning" of the features.
Well, practice makes perfect....I guess I'll start a new Stack and see what happens.

As a side thought, is either way better than the other?

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Data Grid issue after deleting rows

Post by Klaus » Fri Aug 11, 2017 4:01 pm

Hi mrk,
mrk wrote:As a side thought, is either way better than the other?
nope! Since both do what they are exspected to do and there are really no speed issues here, use whatever you like better. :D


Best

Klaus

mrk
Posts: 21
Joined: Mon Apr 03, 2017 6:16 am
Location: Perth, Western Australia

Re: Data Grid issue after deleting rows

Post by mrk » Fri Aug 11, 2017 4:06 pm

Thanks again. Think I may need to sleep on it now...its nearly tomorrow.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”