This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Has anyone sucessfully implemented a windows form, that contains a grid, using the MVP framework with Lightspeed? In particular, how do you manage the delete rows functionality? I am completely new to MVP, and we are just starting to look in to it. But I am confused by the fact that the view should contain no serious logic, just display the data. If this is the case, and because of the LS feature that you can only perform collection deletes from within a UOW, short of having a uow in the view, I do not see how we can perform deletes? Until now in our other apps, prior to using LS,we had simple methods in our business logic to fetch a dataset full of linked tables. We would then modify the data, including deletes, then pass the dataset back to another business logic function that reattach the sataset to the data adaptor, an save all the changes. When we moved to LS we tried to maintain the same isolation, except now instead of passing a dataset, we would pass a list<entities>, with their collections for the child tables, i.e. on get function would return the List<>, the make changes, and a second function would have the modified list passed back to it, and save the changes. This second option worked fine, unless we needed to delete collection entities, especially in grids, so now some of our forms must open their own uow, which sta open for as long as the form stays open, in a few cases this can potentially days or weeks. But back to my original question, without putting a uow in the View, a big no no from what I understand, how can I delete collection items? |
|
|
Hi Mark, Thanks for your post. Indeed I just checked and our WinForms sample does not feature a delete capability (we have add, edit and obviously view items... but no delete). I'll put updating that on our backlog, however in the meantime here's the general flow: - Wire up your event handler for the delete action on your grid A few things to consider: - You'll want to rebind your view with the updated data which will now be missing a row. State tracking such as the selected index etc may be something you want to track so that the delete appears as seamless as possible. If you review the WinformsSample, you'll see an example of how to pass up to the presenter what you wish to edit which would be similar to what you want to do with the start of the delete handler - pass up the item to delete. You may also want to review the Add handler for how it rebinds the view after the add is completed. I hope that gives you some rough idea of how to achieve your goal here :-) Keep us posted on how you find working with the MVP pattern as it can be a bit of a challenge to get working elegantly when you first start using it. Cheers, John-Daniel |
|