display data on dataview retrived from database

-1
i have Question as my  Entity My questions are stored in my database..i want to retrive all the questions and display in dataview widget how can i achive this. because in listview  it has the in built functionality to retrive data from database.. i am trying to with microflow and action is retrive but it is not working
asked
4 answers
3

You can only display one single Object of your entity in a dataview. If you want to show “all” question objects, you can only do this in a DataGrid, TemplateGrid or ListView.
If you want to show a single Object, you can do this in a dataview. You can retrieve it via an association from the object wrapped around your dataview (but this only works if the assiciation is 1-1 or *-1) or by doing it in a microflow. But you need to return one single object and not a list.

answered
1

If you want to retrieve all questions from your database and display them in a data view widget in Mendix, you can follow these steps:

  1. Create a Microflow:

    • Create a new microflow to retrieve the questions. Let's call it "RetrieveAllQuestions."
  2. Add a 'Retrieve' Action:

    • Inside the microflow, add a "Retrieve" action.
    • Choose the entity that represents your questions (e.g., the "Question" entity) as the source of retrieval.
  3. Configure the 'Retrieve' Action:

    • Configure the "Retrieve" action to retrieve all instances of the question entity. You can do this by setting the constraints to an empty list.
    • Make sure the "Retrieve in" property is set to "New context" or "Current context," depending on your use case.
  4. Create a Page:

    • Create a new page where you want to display the questions.
  5. Add a Data View Widget:

    • Drag and drop a "Data View" widget onto the page.
  6. Configure Data Source:

    • Configure the data source of the Data View to be a microflow.
    • Select the "RetrieveAllQuestions" microflow you created.
  7. Add Widgets to Display Questions:

    • Inside the Data View, add widgets to display the properties of each question. For example, if a question entity has a "Text" attribute, add a text widget to display the question text.
  8. Test:

    • Run your app and navigate to the page where you added the Data View widget. You should see all the questions displayed.

Here's a brief outline of the steps in Mendix Studio Pro:

  1. Create Microflow:

    • Open the "Microflows" section in the "App Explorer."
    • Right-click to create a new microflow.
  2. Add Retrieve Action:

    • Drag the "Retrieve" action from the toolbox and configure it to retrieve all instances of your question entity.
  3. Create Page:

    • Open the "Pages" section in the "App Explorer."
    • Right-click to create a new page.
  4. Add Data View:

    • Drag a "Data View" widget onto the page.
  5. Configure Data Source:

    • Select the "Data Source" property of the Data View to be a microflow and choose your "RetrieveAllQuestions" microflow.
  6. Add Widgets:

    • Inside the Data View, add widgets to display the question properties.
  7. Test:

    • Run your app and navigate to the page to see the questions displayed.

Make sure that your microflow is correctly configured, and the attributes you want to display in the Data View are included in the microflow. If you encounter issues, check the console for any error messages that might provide insight into the problem.

 

 

answered
0

Most easy way is to go to the Domain model, right click on the entity and ‘Generate overview pages’. That will give you pages Question_Overview and Question_NewEdit. The first will have a datagrid containing the answers.

NB. A Dataview that you mention, only shows one object of the entity.

answered
0

i THink all the answers are correct

answered