This article was moved to MDriven Wiki – WECPOF Goodies 2–GridAction
It is real easy to create an action that creates objects – but the result is not always very user friendly. It is not friendly to force the user to first hit a button to create a new row in a grid – then move to the new row to enter the text.
We made an effort to solve this issue in a generic way. We call the solution GridAction.
Given this model
And this view model
You can get this WECPOF UI
Now we can very well require that the user first press the action “Create Class1” and then navigate to the new row and enters Attribut1.
But by adding an Action to the Nesting in Viewmodel that the Grid displays we get another way of doing it – the GridAction way:
By doing this – WECPOF adds a null row at the bottom of the lines in our grid:
The null row has the Action name on it – written in italic to separate it from normal rows (representing Class1 objects in this case).
User can write into the GridActionRow, and when user press enter or otherwise submit the edit this will happen:
1. A ViewModel context variable called vGridActionArgument will be assigned the text you wrote
2. The action will execute
So consider this implementation of the GridAction_NewClass1 action:
let x=Class1.Create in
This will create a new Class1 object and assign the Attribute1 to the value entered in the GridActionRow:
The user experience is a lot better!
In the Class2 grid – that in this ViewModelView is a detail of the Class1 master – the GridAction expression looks like this:
let x=Class2.Create in
So it both gets the new name and assigns to the correct Class1 owner – and the user just typed the name in the last row and pressed enter.
If you make use of multi variable seekers – it is desirable to let the GridActionArgument in some grid act as the search expression.
So if you have a UI that enables you to add tenants to houses:
You want to user to be able to search and add in one blow – add a GridAction that is defined as this:
And the Search UI:
Now – when the user types and press enter this will happen:
1. vGridActionArgument gets the typed value
2. The action is executed
3. The action is defined to bring up the Seeker for Person
4. The vSeekParam that is used as filter will be set by the actions OnShow expression
5. WECPOF MAGIC will detect that this is a seeker and press enter – thus starting the search
6. If the result of the search is 1 exactly 1 then WECPOF MAGIC will recognize this as a good result and execute the After Modal Ok expression and thus closing the search UI and also assigning the tenant.
7. If the search result was different than 1 (zero or many but not 1) the search UI will stay open – so that the user can find some other criteria
So the result was 2 rows – the search stays open…
Only 1 hit so everything is done for me: