Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

Problem in Filtering data in SAP UI5 received from Netweaver Gateway using Odata Model

$
0
0

Hi,

 

Problem with filtering OData model.

 

1) I have a autocomplete control.

2) I bind this auto complete field to the data which I received in the OData model from gateway server.

3) Now, user selects a particular value and populates the auto-complete field.

4) User clicks on a button. When the button is clicked, my table should be displayed with that particular shopping Cart item.

 

Basically I am trying to get all the data from Netweaver gateway and then filter it at the client side. However, I get all the data displayed as rows in table so I think my filter for OData is not working. Please let me know what mistake I am doing. Thanks in advance.

 

Below is the code I am using..

 

-------------------

 

var arr = [];

 

var oButton =new sap.ui.commons.Button({text : "Search"});

var oAutoComp = new sap.ui.commons.AutoComplete();

              

var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZSCAPP_SRV/");       

new sap.ui.getCore().setModel(oModel);   

               

oAutoComp.bindItems({ path : "/TDataSet", template : new sap.ui.core.ListItem({text : "{Scid}"})});

               

var oTable = new sap.ui.table.Table({width : "100%", visibleRowcount : 5});

 

oTable.addColumn(new sap.ui.table.Column({label : new sap.ui.commons.Label({text : "Scid"}), template : new sap.ui.commons.TextView({text : "{Scid}"}), visible : true}));       

               

oTable.addColumn(new sap.ui.table.Column({label : new sap.ui.commons.Label({text : "Amnt"}), template : new sap.ui.commons.TextView({text : "{Amnt}"}), visible : true}));

 

oTable.addColumn(new sap.ui.table.Column({label : new sap.ui.commons.Label({text : "Zdesc"}), template : new sap.ui.commons.TextView({text : "{Zdesc}"}), visible : true}));

 

oTable.addColumn(new sap.ui.table.Column({label : new sap.ui.commons.Label({text : "Sctyp"}), template : new sap.ui.commons.TextView({text : "{Sctyp}"}), visible : true}));

 

oTable.addColumn(new sap.ui.table.Column({label : new sap.ui.commons.Label({text : "Createdby"}), template : new sap.ui.commons.TextView({text : "{Createdby}"}), visible : true}));

 

oTable.addColumn(new sap.ui.table.Column({label : new sap.ui.commons.Label({text : "Pdate"}), template : new sap.ui.commons.TextView({text : "{Pdate}"}), visible : true}));

               

oTable.bindRows({path: "/TDataSet"});

               

oButton.attachPress(function(oEvent){

                   

var autoVal = oAutoComp.getValue();

var listBinding = oTable.getBinding();                   

var f1 = new sap.ui.model.odata.Filter('Scid', [{operator:"EQ", value1:autoVal}]);

listBinding.filter([f1]);           

 

               });

               

arr.push(oAutoComp);

arr.push(oButton);

arr.push(oTable);

               

return arr;

 

---------------------------------------


Viewing all articles
Browse latest Browse all 6178

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>