Reputation: 1511
I am trying to extend the sap.m.Table control following this article Everything is working fine. The control is rendering and displaying all content correctly.
But the event will not be fired. What am I missing? Do I have to hook on to a different event? I thought I can just override the onItemPress event of the sap.m.Table control and enhance it the way I want, since I don't need the original functionality.
Any pointers to a solution would be appreciated.
Before trying to extend the control I already tried to hook on to the onItemPress event by using .addEventDelegat()
, which did not work either.
My extended Control:
sap.m.Table.extend("CollapsableGroupTable",{
metadata:{
events:{
"groupCollapse" : {}
}
},
onItemPress : function(evt) {
this.fireGroupCollapse();
},
renderer : {}
});
My instance of the control:
var oTable = new CollapsableGroupTable({
columns : [
<some columns>
],
items : {
path: "<somePath>",
sorter : <someSorter>,
factory : <someFactoryFunction>
},
groupCollapse : function(){console.log("group collapse event fired");},
});
Edit: Just for clarification the override of the event not working is idependent of the item type. I tried with active as well as with inactive.
Upvotes: 0
Views: 393
Reputation: 929
By default the type property of ListItem will be inactive, so that the itemPress event will be ignored. Change you ListItem type to 'Active'.
https://sapui5.netweaver.ondemand.com/sdk/#docs/api/symbols/sap.m.ListBase.html#event:itemPress
https://sapui5.netweaver.ondemand.com/sdk/#docs/api/symbols/sap.m.ListType.html
Upvotes: 0
Reputation: 2412
onItemPress
is an external Event.
You should check which function in sap.m.Table
is triggering that event and override that function to also trigger your event.
Upvotes: 1