Skip to Content
0
Mar 08, 2021 at 03:12 PM

Biding datePicker

62 Views

I'v got 2 date picker's in my project and I want to change one datePicker and change the other.

For some reason when I change one the other one didn't change.

Can you please help?!

This the one I attach an event -

<DatePicker id="docDueDeteId" width="10rem" change="onChangeNecessidadeGeral">
<layoutData>
<OverflowToolbarLayoutData priority="NeverOverflow"/>
</layoutData>
</DatePicker>

This is the one It will change after I change the first one:

<t:Column width="9rem" id="colDateId">
<Label text="Necessidade"/>
<t:template>
<DatePicker id="colDateId1" dateValue="{jModel>necessidade}"/>
</t:template>
</t:Column>

In the controller:

onChangeNecessidadeGeral: function (oEvent) {
var data = oEvent.getSource().getDateValue();
var typeRequest = this.getView().byId("typeRequestId").getText();
var that = this;
var txtWarning = "Do you want to change in the other date fields?";
MessageBox.warning(txtWarning, {
actions: [MessageBox.Action.OK, MessageBox.Action.CANCEL],
emphasizedAction: MessageBox.Action.OK,
onClose: function (sAction) {
if (sAction !== "CANCEL") {
that.changeNecessidade(data, typeRequest);
}
}
});
},
changeNecessidade: function (data, typeRequest) {
var oView = this.getView();
if (typeRequest === "Artigo") {
oView.byId("colDateId1").setDateValue(data); 
} else if (typeRequest === "Serviço") {
oView.byId("colNecessidadeId1").setDateValue(data);
}
}