deleting data grid row and committing db change on save
Posted: Sun Sep 28, 2014 10:28 pm
Hi Guys,
I'm having difficulty into trying to create a 'process' to delete a record. I've designed an app, where a card loads up and any edits for that card are done through a modal dialog. The dialog window continues to have a save and cancel button which either commits a change or not. My card contains a datagrid, and I have some code (below) which deletes a row of data in a datagrid.
I know with the code above I can insert in a sql delete query to remove the offending record however I have a save/cancel button on this dialog card. I want to use the save button to delete the the records in the database file (cancel button should not delete records in db even though datagrid may have been deleted). What I can't figure out is how I can pass the deleted ID's of the lines so I can delete the appropriate records in my db. Is there any merit in storing the deleted keys as a custom property and if save is clicked I use the keys to delete actual records.
Another thought I had was on the save button, I should delete all the lines corresponding to myGrid and then rewrite all the data in myGrid back to the db. This just sounds very inefficient way of doing it.
Anyone advise me any other ways I can record a deleted/hidden row and then pass on the relevant key(s) of the deleted record(s) on the save button to the delete sql query.
Many thanks
Jalz
I'm having difficulty into trying to create a 'process' to delete a record. I've designed an app, where a card loads up and any edits for that card are done through a modal dialog. The dialog window continues to have a save and cancel button which either commits a change or not. My card contains a datagrid, and I have some code (below) which deletes a row of data in a datagrid.
Code: Select all
on MouseUp
local tSelectedRowList
put the dgHilitedIndexes of grp "myGrid" into tSelectedRowList
if (tSelectedRowList is not empty) then
answer "Really delete this line?" with "Delete" or "Cancel"
if (it is "Delete") then
send "DeleteIndex" && tSelectedRowList to grp "myGrid"
end if
end if
end MouseUp
Another thought I had was on the save button, I should delete all the lines corresponding to myGrid and then rewrite all the data in myGrid back to the db. This just sounds very inefficient way of doing it.
Anyone advise me any other ways I can record a deleted/hidden row and then pass on the relevant key(s) of the deleted record(s) on the save button to the delete sql query.
Many thanks
Jalz