Datagrid row modification message

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
dcpbarrington
Posts: 87
Joined: Tue Nov 13, 2007 6:40 pm

Datagrid row modification message

Post by dcpbarrington » Tue Apr 16, 2013 10:02 pm

I'm looking for a way to determine if a row in a datagrid has been modified when a user can Edit the contents.

I have a Table datagrid with a combination of Text fields and Option Menu elements in each of the columns. I created it using DGH which simplified the layout process.

I created a MODIFIED column in the datagraid that contains a flag that indicates that the row has been changed and needs to be saved to the DB.

I have also added the following handler to the datagrid table script to set the MODIFIED flag of the selected row if the contents are changed.

Code: Select all

on CloseFieldEditor pFieldEditor
   dispatch "SetDataOfIndex" to group "StepTable" \
         with the dgHilitedIndex of group "StepTable", "Modified", "True"
   pass CloseFieldEditor 
end CloseFieldEditor
This handler works great when ever a Text field is modified, but does not identify if a Option Menu has been changed. I tried to add a script to the Option Menu object, but could not access the script from DGH.

Is there a message or a script that can be added to capture when the Option Menu value has been changed.

Thanks in advance for the help.

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: Datagrid row modification message

Post by snm » Tue Apr 16, 2013 10:57 pm

You can monitor messages sent in the Message Viewer in LC UI.

Marek

dcpbarrington
Posts: 87
Joined: Tue Nov 13, 2007 6:40 pm

Re: Datagrid row modification message

Post by dcpbarrington » Tue Apr 16, 2013 11:29 pm

The message "menuPick" is generated, but if I put a message handler in the datagrid script on the card it is never called. The message must be getting caught earlier by the datagrid. The question is where does this need to go so it is properly executed?

Code: Select all

on menuPick
   dispatch "SetDataOfIndex" to group "StepTable" \
         with the dgHilitedIndex of group "StepTable", "Modified", "True"
   pass MenuPick
end menuPick

dcpbarrington
Posts: 87
Joined: Tue Nov 13, 2007 6:40 pm

Re: Datagrid row modification message

Post by dcpbarrington » Wed Apr 17, 2013 4:13 pm

Found where the datagrid puts the menuPick handler.

A behavior button is created for each column by DGH. In each of the behavior buttons is the menuPick handler. Here is what I added to make it set the modified flag.

Code: Select all

on menuPick pTheMenuItem
   switch the short name of the target
      case "TitleButton"
         SetDataOfIndex the dgIndex of me, the dgColumn of me, pTheMenuItem
         SetDataOfIndex the dgIndex of me, "Modified", "True"
         RefreshIndex the dgIndex of me
         break
   end switch
end menuPick

Post Reply