hold data on UI and the on clicking a button the data will save in database

0
i want to save my data  on Ui not directly in database for an entity,  and after saving the data on UI i want to create the new object of same entity and again save on UI,after this on clicking a button i want to save this complete data(data in both objects together)  in database on one click only .how can i achieve this fuctionality
asked
3 answers
0
  1. Hi Dheeraj,

    As Rene suggested , I will also recommend to go through the below learning path
    https://academy.mendix.com/link/paths/31/Become-a-Rapid-Developer

    I will also try to explain it to you how we can create something like which you want in below example.

    As per your requirement you want to have multiple objects created on the page but want to save it at the end together ,
    so to hold these objects together you want some sort of container where you will keep objects together.

    In mendix we have entities so idea would be to make one entity as a container and keep these objects in them .

    Having this in mind what we can do we can create a entity as our container and have a one to many association to the actual objects which we want to create in the memory ( where this container entity will have one to many association with the objects which you want to create)

    Domain model will look as below:



    Here For example I want to create multiple registration and store them at last for one student.


    Then you can create a page like this.

 

Here you can have a data view with a data source microflow to fetch the Student object(container) and then you can have a list view of registration with data source as association (because you want to work with memory objects)

Now you can have button in data view which will create objects for your registration and open a pop up page (make sure to link your new registration object with student object )



In this pop up page instead of default save button you can call another microflow to refresh the student object to show newly created object only and not save it.




 

After that you can add as many registrations you want in memory and they will appear on the page.

Now you can use the save button of the data view student object to commit them together.






This way you can create the desired functionality.

I would still suggest to go through learning paths , as there can be other approaches also for doing this requirement and this explanation is only to help you understand the specific use case.

Hope this helps !

Regards,
Sunit Kumar Dubey

answered
0

Hi Dheeraj Bhardwaj,

To show created objects on UI without commit,you needs to have Dataholder entity in domain model with association(1 to many) with entity A(which you want to manage). In your database you always needs to have only 1 obj of Dataholder to hold all A objs. now on A obj overview page where you are showing all objects of A. There you needs to have dataview of Dataholder with microflow as datasource. In that microflow you need to check Dataholder obj available or not by retrieving it from database, If available then return that obj else create new object and return. Once you get that obj in data view, inside dataview you will have datagrid of A which will show all A objects associated to that Dataholder. Whenever you create new obj of A and associate to Dataholder then you will see that A obj in datagrid without commit.

And lastly you will have one btn(commit objs) in Dataholder object context which will call microflow – in that microflow you will pass that dataholder parameter and then you can commit that dataholder and all associated A objs.

Hope this helps you, Kindly comment if any clarification required.

Thank you.

answered
0

Hi Dheeraj,

 

Mendix uses objects to capture the data. Also in the UI. So no need to “Save it in the UI”

 

Looks like you want to create multiple objects and add them to a list.

First question; what is the combining factor between these objects. For example orderlines are part of a order. Thus the combining factor is the Order. This allows you to work in context of the order and add orderlines to the order using a association.

Second question: did you follow the rapid developer course of the Mendix academy?

https://academy.mendix.com/link/paths/31/Become-a-Rapid-Developer

If not (based on your points, it looks like this) please follow this course and especially check how registrations are added to a trainingevent

answered