Working with nested datasets
I have to make clear one thing (I've omitted from my Help file- I'll update it in a future release) relevant to forming a master/ detail relationship on app server and having a nested dataset structure on client side. ForeignKeys property doesn't apply to fields representing the "connector" field in nested datasets. I'll be more specific with an example (the same as in a previous post):
I'll probably add better support (solve issues 5 and 6) to nested dataset structures in a newer version of KT Data Components.
- Create the following tables in a back-end database
- Categories
- CatID:Integer
- Name: VarChar(50)
- Items
- ItemID:Integer
- Name: VarChar(50)
- ItemCat
- ItemCatID:Integer
- CatID:Integer
- ItemID:Integer
- Create relationships
- ItemCat.CatID foreign key referencing Categories.CatID with on update rule set to CASCADE and delete rule set to SET NULL
- ItemCat.ItemID foreign key referencing Items.ItemID with on update and delete rule both set to CASCADE
- Build an application server and form a master/ detail relationship between Items (master table) and ItemCat (detail table) and hook a TKTDataSetProvider to Items dataset. Create another TKTDatasetprovider and hook it on Categories dataset
- Build a client application and create three Cds (and build their persistent fields):
- CategoriesCds (set providername prop to respective TKTDatasetprovider component)
- ItemsCds (set providername prop to respective TKTDatasetprovider component)
- ItemCatCds (Set DataSetField prop to the created DatasetField of ItemsCds)
- You should only set CategoriesCds.ForeignKeys property to "ItemsCatCdsCatID=9" and NOT ItemsCds.ForeignKeys:="ItemsCatCdsItemID=10". That is, you should only set the ForeignKeys property for a field that doesn't belong to the same nested dataset structure.
- In addition, you should set a handler for ItemsCatCds OnNewRecord event and add this line (or else ItemsCatCdsItemID will have a null value and this will create problems when trying to use BatchApplyUpdates) :
- ItemsCatCdsItemID.Value:=ItemsCdsItemID.Value;
I'll probably add better support (solve issues 5 and 6) to nested dataset structures in a newer version of KT Data Components.
0 Comments:
Δημοσίευση σχολίου
<< Home