I want to dynamically change the style of a sap.m.CustomListItem
of my list when I click on a button.
I used addStyleClass
and it works only in the onInit
method but not in the press` function, the style has been added but the view doesn't change.
Controller
pressbutton: function(oEvent) {
var o = oEvent.getParameter("value");
MessageToast.show(o.toString());
var listitem = this.getView().byId("IDCustomerListItem");
if (listitem.hasStyleClass("myListItemClass")) {
this.getView().byId("IDCustomerListItem").removeStyleClass("myListItemClass");
this.getView().byId("IDCustomerListItem").addStyleClass("myListItemClasso");
} else {
this.getView().byId("IDCustomerListItem").addStyleClass("myListItemClass");
}
}
CSS
.myListItemClass {
width: 50% !important;
float: left;
}
.myListItemClasso {
width: 100% !important;
}