on 10-11-2018 9:10 PM
Hi ,
I am new to SAP ui5,
Want to know, is it possible to get the data into the table field based on previous field change?
I have a table which is bound to an XML model.
On entering/changing the value in field1 want to display the field2 value from odata service.
i have created the Odata service which contains material and description.
I am using the following code in controller.js
Onchange: function(evt){
var Zmatnr = oTable.getRows()[i].getCells()[1].getValue();
var modelUrl2 = "../../../../../../sap/opu/odata/SAP/ZMATNR_NEW_SRV/";
var oModel = new sap.ui.model.odata.ODataModel(modelUrl2,true); sap.ui.getCore().setModel(oModel,"modelName2");
var aFilter = new sap.ui.model.Filter("Material", sap.ui.model.FilterOperator.EQ, Zmatnr);
/**** Here Please help me with some logic how to *****/
}
Here user will enter the Material number in the first row field of the table , then in automatically in the second field the description should appear.
Please let me know how to build the logic for this.
Regards,
kasi.
After you apply the filter, you should implement code to read the selected rows
var oToken = oEvent.getParameter("tokens");
oSelectedRow = oToken[0].getAggregation("customData")[0].getProperty("value");
then you can use method setValue to set the description
this.getView().byId("yourDescriptionID").setValue(oSelectedRow.yourDescriptionContent);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Binh,
Thank you for the reply.
But based on the filter value need to get the data for another field from different entityset.
my odata service is as follows.
var modelUrl2 = "../../../../../../sap/opu/odata/SAP/ZMATNR_NEW_SRV/";
var oModel = new sap.ui.model.odata.ODataModel(modelUrl2,true);
sap.ui.getCore().setModel(oModel,"modelName2");
var Zmatnr = oTable.getRows()[i].getCells()[1].getValue(); " Getting the Table row first field.
Passing to the filter
var aFilter = new sap.ui.model.Filter("Material", sap.ui.model.FilterOperator.EQ, Zmatnr);
Now there is new Entity set "MaterialDetails" which contains Matnr and description.
Following is the table
Matnr Description Price
On entering matnr in first field decription need to auto populate.
Here i need help to get the description from the new entityset and bind it to the second field.
Thanks,
Prakash.
Do you mean that right after you get the Zmatnr, it will be pass to another entity (MaterialDetails) and from there, you will get the description?
If so, right after you get Zmatnr, you should apply the filter with "MaterialDetails" instead of "Material", then refer the code I posted above to retrieve the description and set it.
Regards,
Binh
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.