Skip to Content
0
Former Member
Feb 27, 2014 at 01:22 PM

RadioButton updates Model (Odata)

65 Views

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.