on 03-08-2021 3:12 PM
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);
}
}
hi, this code work fine but your second datepicker is in table so you need to check this.getView().byId("typeRequestId").getText(); its proper work or not and other way is using formatter
hope it helped you
onChangeNecessidadeGeral: function (oEvent) {
debugger;
var data = oEvent.getSource().getDateValue();
var typeRequest = "demo";
var that = this;
var txtWarning = "Do you want to change in the other date fields?";
sap.m.MessageBox.success(txtWarning, {
actions: [sap.m.MessageBox.Action.OK, sap.m.MessageBox.Action.CANCEL],
emphasizedAction: sap.m.MessageBox.Action.OK,
onClose: function (sAction) {
if (sAction !== "CANCEL") {
that.changeNecessidade(data, typeRequest);
}
}
});
},
changeNecessidade: function (data, typeRequest) {
var that = this;
if (typeRequest === "demo") {
that.byId("colDateId1").setDateValue(data);
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
What is the error message you are getting..
Hope the conditions on typeRequest are not satisfying.
Below is the quick example for your reference.
View:
<DatePicker id="DP1" placeholder="Enter Date 1" change="handleChange1"/>
<DatePicker id="DP2" placeholder="Enter Date 2" change="handleChange2"/>
controller:
handleChange1: function(oEvent)
{
var sDate1 = oEvent.getSource().getDateValue();
this.getView().byId("DP2").setDateValue(sDate1);
},
handleChange2: function(oEvent)
{
var sDate2 = oEvent.getSource().getDateValue();
this.getView().byId("DP1").setDateValue(sDate2 );
},
Hope it helped you!
Rajesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your aswers.
I didn't explained myself properly.
One of the <datePicker>'s is inside a grid table who is fulfill by a jsonModel.
I found the solution, just changed the value of the property in the model and the value of the datePicker inside the table change.
onChange: function (data, typeRequest) {
var myData = this.jModel.getProperty("/requestSpecific"),
oDataLength = myData.length,
oModel = this.jModel,
i;
for (i = 0; i < oDataLength; i++) {
oModel.setProperty("/requestSpecific/" + i + "/necessidade", data);
}
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.