rho
Posts: 85
|
| Posted: 02/27/2006, 12:53 PM |
|
How do I validate a row in an editable grid and be able to cancel the deletion of the row?
F.e. I want to delete a row *only* if the primary key of the row isn't used in some other table (referential integrity).
I've been trying to use the OnValidateRow() event, but this event isn't triggered for a row that has the Checkbox_Delete control checked. I don't get other events to work either. How can this be done?
Anybody any suggestions/hints/links/tips?
TIA, Rob.
|
 |
 |
peterr
Posts: 5971
|
| Posted: 02/27/2006, 1:39 PM |
|
Cancelling record updates and deletions is described in the following section of the documentation (Help): "Prevent Operation for Individual Records via Editable Grid".
Hopefully that will work in your case as well.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
rho
Posts: 85
|
| Posted: 02/27/2006, 7:33 PM |
|
Thanks. This gets me started! However, when trying to get to the value of a field on the row to be deleted (e.g. Tasks.User_Name.value), I get the value of the *last* row of the editable grid and not the value of User_Name on the row that is to be deleted. How do I do that?
|
 |
 |
peterr
Posts: 5971
|
| Posted: 02/27/2006, 9:08 PM |
|
Maybe this post would help: http://forums.codecharge.com/posts.php?post_id=60507
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
mhope
Posts: 37
|
| Posted: 02/28/2006, 2:19 AM |
|
Let me see if I understand correctly, you want to delete a row if the primary key (field) isn’t used in another table? If so this should work:
In a before show event would do:
DELETE FROM Table1 WHERE Field1 IN (SELECT DISTINCT Field1 FROM table2)
|
 |
 |
dragoon
Posts: 173
|
| Posted: 02/28/2006, 7:06 AM |
|
DELETE FROM Table1 WHERE Field1 NOT IN (SELECT DISTINCT Field1 FROM table2)

Quote mhope:
Let me see if I understand correctly, you want to delete a row if the primary key (field) isn’t used in another table? If so this should work:
In a before show event would do:
DELETE FROM Table1 WHERE Field1 IN (SELECT DISTINCT Field1 FROM table2)
|
 |
 |
mhope
Posts: 37
|
| Posted: 02/28/2006, 12:10 PM |
|
Yes, sorry forgot the "Not"
|
 |
 |