This project is read-only.

[Solved] How to get data from a modal view

May 16, 2015 at 7:22 AM
Edited May 16, 2015 at 7:34 AM

i have create a small view to select a printout from a list. I show the list as a modal view.

How can I get the selected information from the View? the view use a Viewmodel with a property SelectedPrintout

I open it with
Controller.Action("PrintManagement", "SelectFromKeyValuePair", New With {.param = _KVPParam})
The controller looks like
        Public Function SelectFromKeyValuePair(param As KeyValueListProperties) As ActionResult

            Return ViewModal(New SelectFromKeyValuePairViewModel(param), ViewLevel.Popup)

        End Function
The code for closeing the modal View is a ActionButton
        Actions.Add(New ViewAction("Drucken", execute:=Sub(action, parameter) Controller.CloseViewForModel(Me)) With { _
      .Significance = ViewActionSignificance.Normal})
Thanks for the goog help here on this project
May 18, 2015 at 11:44 PM
Controller.Action() returns a context object. So something like this allows you access to that:
var context = Controller.Action(...);
That context object exposes various interesting things, such as the view-model that is used. It also has events that fire when the view closes (and such). So you can simply wire up an event handler so you know when the view closes, and then access the associated view-model and its data. So you could easily launch a view from one form, then listen for the close event, and then grab the data and do something in the original view. An example scenario would be launching some kind of search screen and then see what was selected.

May 20, 2015 at 1:02 PM
Thanks for that info. That was helpfull. Now it is working fine