You can add new rows and delete existing rows. For simple Data Trees containing a single Entity this is straight forward. For complex Data Trees containing relational data it can be more complex, as the related rows in other Entities also needs to be considered.
Adding and deleting rows is done using the icons in the grid view or form view toolbars:
Icons |
Descriptions |
|---|---|
Add a new row to the end of the data |
|
Delete the selected row(s) |
Clicking on the 'New row...' icon will open a dialog that lets you specify the data to add. The Entity to which the row is added is determined by the current selection. In the grid view there is only one Entity present, but a form can contain multiple Entities. The currently selected widget is used to determine to which Entity the row is to be added. For instance, if you have selected a detail Entity then the row will be added to this, but if you have a widget from the master Entity selected (or no selection) then the master Entity (the one at the root of the Data Tree) will be used. When the new row is added it will appear as the last record of your data e.g. as the last row in a grid view or table widget or as the last record of a form.
In most cases the meaning of adding a new row is obvious - a new row of data will be added to the database. But in the case of a many-to-many relationship there is also the possibility of wanting to specify that an existing row should be added rather than a new one, as each row in an Entity involved in a many-to-many relationship can be related to multiple rows in the corresponding Entity.
To accommodate this the 'New Row...' dialog has two modes:
In the case of detail data the new row that is added is always added in the context of the selected master row e.g. there must only be a single row selected in the master and the new row will be added as a related row to that master row. It is not possible to add a detail row without it being associated with a master row. If you need to do this you must create a data tree with the required Entity as the root element.
In this mode you need to type in the values for the new row and click on the 'Add' button. The new row will be added to the end of the dataset. The dialog will remain open, allowing you to add another row.
In this mode you specify the ID of the existing row that you wish to add. You can click on the 'Fetch' button to view the row to check that it is the one you want. Clicking on the 'Add' button will add that row as a new related row to the selected master row.
Similarly to inserting rows, deleting them is usually straight forward, but there are complications when deleting rows from relational data. Where the row you are deleting is involved in a relationship to mulitple rows (in the case of a one-to-many or many-to-many relationship) it is necessary to distinguish between just deleting the row for just the current entry and deleting it completely from the database, in which case it will also be deleted from any other rows that reference it.
Consequently, in these scenarios the delete row dialog lets you distinguish between these needs. Make your choice carefully!
Another factor that can affect deleting rows from relational data is the setting for the 'On Delete' action in the database constraint that was created when the relationship was created. For instance if the CASCADE option was chosen then related rows will be automatically deleted for you, but other options will leave them in place, or may prevent deletion of the row until all related rows have been removed. Consult your database documentation for full details.
Because of these potential complications in deleting rows you are advised to test that the behavior is what you expect with some test data first.
When rows are added or deleted IJC makes no attempt to reflect the current query status. Thus your new row may be visible, even though it does not match your current query criteria. We think this is more intuitive than adding the row to the database but then potentially not displaying it. To query should be re-run if you want the displayed data to be correct.
Copyright © 1998-2008 ChemAxon Ltd. All rights reserved.