Delete Line In Data Grid

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
KennyR
Posts: 256
Joined: Thu Jan 19, 2012 4:25 am

Delete Line In Data Grid

Post by KennyR » Fri May 17, 2013 5:39 am

I know this is most likely a simple solution, but I cannot seem to figure this out. I have a DG Form that I have customized with a few buttons and fields. One of the buttons is an "Edit" button that takes the text from the various fields that reside in the row and places them in another card for editing. This all works fine, but I cannot seem to delete the hilited line of the data grid within the script of the button that resides inside the row template group. If I place a button outside of the DG row template group, deleting the line works fine. I think it is just how I am referring to the object since it is inside this group. Just so you know, I have been reading other posts and lessons to figure this out, so this is my last ditch effort before bed! My script for the button is below...thanks

Code: Select all

on mouseUp
   --Populate the description fld with the DG data
   put fld "orderItem" before fld "description" cd "description"
   put fld "OrderInfo" after fld "description" cd "description"
   put fld "total" into fld "total" cd "description"
   
   --Change the state of the button depending on what size was selected
   if "Small" is among the words of fld "description" cd "description" then set the backgroundColor of btn "Small" cd "description" to "green"
   if "Medium" is among the words of fld "orderItem" then set the backgroundColor of btn "Medium" to "green"
   if "Large" is among the words of fld "orderItem" then set the backgroundColor of btn "Large" to "green"
   
   --Delete the hilited line of the DG
   --This button resides inside the DG Row Template and this is where I am having trouble....

   put the dgHilitedLines of group "DataGrid" of the dgControl of me into theLine
   dispatch "deletelines" to grp "DataGrid" of the dgControl of me with theLine
   
   visual effect "push right very fast"
   go cd "description"
end mouseUp

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Delete Line In Data Grid

Post by bangkok » Fri May 17, 2013 8:22 am

Check the example stack in the file attached.

Disclaimer : i use regular DG, not form.

Here is a method to delete a line, by clicking on a button in a column.

-create a column behavior script

-add the mouseup handler :

on mouseup
answer warning "Confirm deletion ?" with "Yes" or "No"
if it is "no" then exit to top
dispatch "DeleteIndex" to group "mygrid" with the dgIndex of me
end mouseup
Attachments
MYTEST.zip
(4.84 KiB) Downloaded 278 times

KennyR
Posts: 256
Joined: Thu Jan 19, 2012 4:25 am

Re: Delete Line In Data Grid

Post by KennyR » Fri May 17, 2013 2:49 pm

Bangkok...Thank you for your time on my problem...I have downloaded the stack and am unable to access the behavior script....So I cannot see what you put in the script... :(
I am going to keep trying, but again, thank you very much for your help...

Post Reply