I’m trying to create a page with a questionnaire, where users are presented a list of questions and have to answer them. There are multiple types of answers (multiple choice, textfields, numeric ratings, etc.).
I managed to load the questions correctly from my odata service and the view (including the different answer fields) is rendered correctly. But now I’m struggling to actually bind the answer fields to the data.
I have a relation between the questions and the answers in my database, but since the list is auto-generated using the question items, I don’t know how to correctly associate and fill the fields.
I’ve bound the questions like this to the list:
this.getView().bindElement({
path: "/Questionnaire(ID=" + sID + ",IsActiveEntity=true)",
parameters: {
expand: "questions" // Include the questions association
},
events: {
dataReceived: function (oData) {
console.log("Data received:", oData);
},
dataRequested: function () {
console.log("Data requested...");
}
}
});
I’ve already tried multiple things, but I didn’t even manage to retrieve the data and log it to the console or something like that.
Most things I’ve found when searching for a solution use OData v2 where you could use the ‘read’ function of the model to get the data, but since I’m using an OData v4 service this isn’t available to me as far as I understood.
Any help or tips would be greatly appreciated