cancel
Showing results for 
Search instead for 
Did you mean: 

I'm getting getBinding undefined. I have used it twice in init function and onSort function

rhia23
Discoverer
0 Kudos
onInit: function () {
             var otable= this.getView().byId("Table1");
 var oModel = new sap.ui.model.json.JSONModel();
 oModel.loadData("model/data.json");
  var oModel1= this.getView().setModel(oModel);  

 //Initial sorting 
 var sPath, bdesc, aSorters=[] ;
 sPath ="EmpNo";
 bdesc = false;
 aSorters.push(new Sorter(sPath, bdesc));
 this.byId("Table1").getBinding("rows").sort(aSorters);
         },

 onSort : function(oEvent) {

   var mParams = oEvent.getParameters(),
sPath,
bDescending,
aSorters = [];
//sPath = mParams.sortItem.getKey();
   sPath="EmpName";
// bDescending = mParams.sortDescending;
  bDescending = false ;
aSorters.push(new Sorter(sPath, bDescending));
var oList = this.byId("Table1");
this.oList.getBinding("rows").sort(aSorters); }
rhia23
Discoverer
0 Kudos

I have used a sap.ui table in which initially i want to sort it to by EmpNo and when i click on sort button, then it should sort by EmpName. I have used json data in this .

Now in the code, I did sorting in onInit fn and onSort fn but only one is working at a time. In the code, i'm getting error in onSort fn that :- Uncaught TypeError: Cannot read property 'getBinding' of undefined

View Entire Topic
vinibar
Participant
0 Kudos

just replace

var oList = this.byId("Table1");
this.oList.getBinding("rows").sort(aSorters);

with

var oList = this.byId("Table1");
oList.getBinding("rows").sort(aSorters);