Page 1 of 1

Delete Line In Data Grid

Posted: Fri May 17, 2013 5:39 am
by KennyR
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

Re: Delete Line In Data Grid

Posted: Fri May 17, 2013 8:22 am
by bangkok
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

Re: Delete Line In Data Grid

Posted: Fri May 17, 2013 2:49 pm
by KennyR
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...