javascript - Fire a function on an item press in Openui5 -
i want fire "handlerowpress" when press table item. code:
showtable: function(){ var odata=convertdatatable(testdatainput); //make sure table id suffix set (this necessary personalization) var otable = new sap.m.table('testtable', { headertoolbar: new sap.m.toolbar({ itempress: "alert('pippo')", content: [ new sap.m.toolbarspacer({}) ] })/*, columns: odata.cols.map(function (colname) { //make sure column id suffix set homecoming new sap.m.column(colname, { header: new sap.m.label({ text: colname })}); })*/ }); otable.setmodel(new sap.ui.model.json.jsonmodel(odata)); for(var i=0; i<otable.getmodel().getproperty("/cols").length; i++){ otable.addcolumn(new sap.m.column(otable.getmodel().getproperty("/cols")[i], { header: new sap.m.label({ text: otable.getmodel().getproperty("/cols")[i] })})); } otable.bindaggregation("items", "/items", new sap.m.columnlistitem({ cells: otable.getmodel().getproperty("/cols").map(function (colname) { homecoming new sap.m.label({ text: "{" + colname + "}" }); }) })); //otable.setproperty("selectionchange","handlerowpress"); //otable.setproperty("itempress", "handlerowpress" ); //otable.setproperty("select", "handlerowpress" ); otable.attachitempress("handlerowpress"); var mypage=this.byid("pageoperation"); mypage.addcontent(otable); }, handlerowpress : function(){ console.log("clicked on item!!!!"); //console.log(event); } why can't it? if seek set property "itempress" (comment lines) doesn't seem set it.
how can set function without xml view js code?
you can set handler in table-constructor function:
var otable = new sap.m.table({ itempress: function(){ console.log("clicked on item"); } }); or set in constructor reference
var otable = new sap.m.table({ itempress: this.handlerowpress }); or attach function on created table-object
otable.attachitempress(this.handlerowpress); javascript sapui5 sapui
No comments:
Post a Comment