cancel
Showing results for 
Search instead for 
Did you mean: 

RadioButton updates Model (Odata)

Former Member
0 Kudos

Hi,

I am new to sapui5 and I wrote a simple form to edit person's information.

I attached a model to this form and bind a context when user selection changes :


var uri = "/person.xsodata";

var oModel = new sap.ui.model.odata.ODataModel(uri, true);

oModel.setDefaultBindingMode(sap.ui.model.BindingMode.TwoWay);

var oForm = sap.ui.jsfragment("app.view.fragments.PersonInformation", oController);

oForm1.setModel(oModel);

[...]

oForm1.bindContext("/Person("+PersonId+")");

Then I would like to save model changes from the gender using RadioButton, I tried several function handler but was not able to fix it.


function handleSelectGender(e) {

    var g = e.getSource().getSelectedItem().getKey();

   oForm.getBindingContext().getObject().gender=g;

}

If then I call model.submitChanges() nothing happens, as update of Model is not detected. If I change another field and then call it updates will be taken on board.

I tried :


function handleSelectGender(e) {

var iIndex = e.getParameter("selectedIndex");

    oForm.getBindingContext().getModel().setProperty("selectedIndex", iIndex);

}

But there is no update of the model.

Thanks in advance for your help.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I managed to fix it :

function handleSelectGender(e) {
              var g = e.getSource().getSelectedItem().getKey();
              var oBindingContext = oForm.getBindingContext();
              oBindingContext.getModel().setProperty("gender", g, oBindingContext);
}

Answers (0)