Attaching event to a subview datatable

Hi, what would be the right way right to attach a datatable event such as onAfterSelect to a datatable which is in a subview? Giving the subview an id and accessing it through $$(‘subviewid’) on the main table’s onAfterRender doesn’t seem to work

Problem solved. Event should be attached on the main table’s “onSubViewCreate”