Hard time finding a solution

Posts   
 
    
BlueCell avatar
BlueCell
User
Posts: 83
Joined: 12-Jul-2004
# Posted on: 18-Jul-2006 19:45:35   

Currently, I am having a hard time to find a solution for my needs. While using selfservicing, I have a number of tables generated to collections and entities: for example, a application table. Now I have the need of a application (table) maintance screen (master-detail). So I binded the application collections to the grid I am using, and I bind the appropriate (detail) fields. However, a specific field is not stored in the database, but in an active directory! When I switch the row of the application grid the application collection keeps changes untill saved or cancelled, but how to do this for this specific field stored in the active directory?

TIA,

BC

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 19-Jul-2006 07:35:27   

I guess you have to manually maintain this field in code, try to catch the saving event or the selected row changed event (whatever are the names) and manually save those fields in the active directory.

BlueCell avatar
BlueCell
User
Posts: 83
Joined: 12-Jul-2004
# Posted on: 19-Jul-2006 15:58:52   

Actually, I am still having a hard time. So I'll try to clarify as much as possible:

I am using a master-detail form. The master is a grid, and the detail are controls. The grid is databinded to a llblgen collection (A), as are the detail controls containing the data found in collection A. However, inside the detail there another grid, which data isn't found in that collection A. Instead it can be found in a different llblgen collection (B). Collection B has a one-2-many (A-2-B) relationship with A, so I COULD databind it (using the relationship), but that would result in an unwanted result, because the data of collection B isn't the datasource for the detail grid! The datasource of the detail grid is found inside an active directory. After the grid is filled with this data, I am able to select rows in the grid. The selected rows then need to be saved in collection B, using the current entity id of collection A as a FK in collection B (thus the relationship). Selected items should be added to collection A if they do not excist (if they already do, then it is already OK), whereas unselected items which excist in the collection A, should be deleted from it, thus only the selected items excist in collection B.

So, this isn't very hard:

Before row of collection A changes: Loop all items of the detail grid. If selected and not excisting: add it to B. If not selected and excisting: delete it from B. After looping: save to storage (the DB)

After row of collection A changes: Loop all items of collection B and find the corresponding row in the detail grid, and select it.

But now I would like to add a cancel button wink Yikes! Data can't be saved to the DB on "before row of collection A changes"; only save when the "save" button is pressed. This means, that I have to keep track of the collection B of collection A (see the relationship), and that is basically what I need and do not know simple_smile

Sorry for the long post... I hope someone could provide me with a solution soon.

TIA,

BC

Rogelio
User
Posts: 221
Joined: 29-Mar-2005
# Posted on: 19-Jul-2006 17:06:46   

Hi,

Try adding a custom field to the master record, this new custom field have to be a collection. At the begining this collection has to have the same items as your original collection inside each master record. Then you work with this custom field instead of your original collection, you only have to change the logic to use this new collection and do not save to the db until the save button is clicked. When the save button is clicked then do operation of adding the record that are in the new collection; but do not exist in the original collection and delete the items that exist in the original collection; but do not exist in the new collection.

Hope this help.

BlueCell avatar
BlueCell
User
Posts: 83
Joined: 12-Jul-2004
# Posted on: 22-Jul-2006 16:25:14   

Uhm... I still don't understand how to achieve the result I want disappointed You said that I should try to add a custom field to the master record... do you mean adding a property to the CustomEntityCollectionCode region of the master grid llblgen collection ? If so, then how can I set my datasource to that property (in designtime)?

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 22-Jul-2006 19:10:05   

I think Rogelio is probably refering to the following in the munual

Designer - Adding and editing entities - Custom properties sub tab

Rogelio
User
Posts: 221
Joined: 29-Mar-2005
# Posted on: 24-Jul-2006 17:47:43   

BlueCell wrote:

Uhm... I still don't understand how to achieve the result I want disappointed You said that I should try to add a custom field to the master record... do you mean adding a property to the CustomEntityCollectionCode region of the master grid llblgen collection ? If so, then how can I set my datasource to that property (in designtime)?

Hi,

You can add a property of type EntityCcollection inside the: ' __LLBLGENPRO_USER_CODE_REGION_START CustomEntityCode of the entity that actually has the EntityCollection B. You do not have to bind the new collection, because actually you do not have the EntityCollection B binded, you said that the datasource of the details grid is an Active Directory!.

The idea is the following: 1. In the load event of your form: 1.1 For each master entity, add the items that are in the original collection B to the new collection.

  1. Before row of collection A changes: Loop all items of the detail grid. If selected and not excisting in the new collection: add it to the new collection. If not selected and excisting in the new collection: delete it from the new collection.

  2. After row of collection A changes: Loop all items of the new collection and find the corresponding row in the detail grid, and select it.

  3. When the user click the save button: For each master entity, loop all items of new collection, if exist in new collection and not in collection B add it collection B; if not exist in new collection and exist in collection B delete it from collection B. Save to storage.

BlueCell avatar
BlueCell
User
Posts: 83
Joined: 12-Jul-2004
# Posted on: 24-Jul-2006 21:18:31   

Ah great respondses! A big thank you to both of you! One more question though... Rogelio said "2. Before row of collection A changes". Using janusys gridex control, I have not found such an event. I can only retrieve a position changed from the databinding, but that is after row of collection A changes. It would be awesome, if one would have found a nice place to trap this specific event!

Thanks in advanced,

BC

Rogelio
User
Posts: 221
Joined: 29-Mar-2005
# Posted on: 24-Jul-2006 22:08:09   

BlueCell wrote:

Ah great respondses! A big thank you to both of you! One more question though... Rogelio said "2. Before row of collection A changes". Using janusys gridex control, I have not found such an event. I can only retrieve a position changed from the databinding, but that is after row of collection A changes. It would be awesome, if one would have found a nice place to trap this specific event!

Thanks in advanced,

BC

Hi,

It is easy to track, use a variable to keep track of the last position, when the row in collection A changed then use this variable to get last entity from collection A, then after you do all the process assing the new position to this variable to keep track for the next change. You only have to take care at the beginning, because the first time the event occur you do no have a previous position.

BlueCell avatar
BlueCell
User
Posts: 83
Joined: 12-Jul-2004
# Posted on: 24-Jul-2006 22:19:12   

Ah OK! Just what I thought! Thanks for the quick reply...

BlueCell avatar
BlueCell
User
Posts: 83
Joined: 12-Jul-2004
# Posted on: 25-Jul-2006 11:52:48   

A question again! smile

1.1 For each master entity, add the items that are in the original collection B to the new collection.

You said to do this in the form load. Is this the place where you are most comfortable doing so? What about inside the InitClassMembers or CreateNewentityname custom code regions? Any thoughts on that topic?

[EDIT] I tried to see how good this would work inside the InitClassMembers or CreateNewentityname custom code regions: since the AD connection is not setup at design time, you will get connection errors for the design time collection objects. So in form load it will be!