cancel
Showing results for 
Search instead for 
Did you mean: 

CustomListItem no event is fired

steffenretz
Participant
0 Kudos

Hello,

I've tried to fire the press event (or something else ) of a CustomListItem.


<List growing="true" growingScrollToLoad="true" includeItemInSelection="true" items="{path: '/EmployeeSet'}">

     <items id="employeeMasterListItems">

          <CustomListItem id="employeeMasterListItem" type="Active" press="onSelect">

               <Label text="Test" />

          </CustomListItem>

     </items>

</List>

In the controller I have the following method:


onSelect: function(oEvent) {

     console.log("onSelec", oEvent);

}

With Type DetailAndActive I can fire the detailPress event, but nothing else.

Any idea? Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

steffenretz
Participant
0 Kudos

I solved this problem by adding sap.m to the data-sap-ui-libs inside my index.html.

It seems to be that the events of sap.m controls are not properly fired if the library is not preloaded.


<script src="resources/sap-ui-cachebuster/sap-ui-core.js"

     id="sap-ui-bootstrap"

     data-sap-ui-libs="sap.ui.commons, sap.m"

     data-sap-ui-appCacheBuster=" ...and so on... >"

</script>

Answers (3)

Answers (3)

Chantele
Active Participant
0 Kudos

Hi

Have you tried putting a link in your customListItem that will allow you to use the press functionality

<Link text="{Name}" press="handlePress"/>


Also you need to set your controller value in your fragments if they have controls inside them too.


regards

Chantele

Former Member
0 Kudos

hi,

add one line of code in your xml view

controllerName="<your controller name>"

JS Bin - Collaborative JavaScript Debugging

Regards

former_member205488
Active Participant
0 Kudos

Hello!


1) Did you define a controller in the view header?

2) Is there any errors in the developer console of the browser?

steffenretz
Participant
0 Kudos

The view exists of two fragments.

Main View


<core:View controllerName="view.Employee" xmlns:core="sap.ui.core" xmlns="sap.m"

    xmlns:html="http://www.w3.org/1999/xhtml">

    <SplitApp id="idSplitAppEmployee">

        <detailPages>

            <core:Fragment fragmentName="view.fragment.EmployeeDetail"

                type="XML" />

        </detailPages>

        <masterPages>

            <core:Fragment fragmentName="view.fragment.EmployeeMaster"

                type="XML" />

        </masterPages>

    </SplitApp>

</core:View>

Fragment with customListItem


<core:FragmentDefinition xmlns:core="sap.ui.core"

    xmlns:footerbar="sap.ushell.ui.footerbar" xmlns:mvc="sap.ui.core.mvc"

    xmlns="sap.m" xmlns:l="sap.ui.layout"

    xmlns:custom="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1">

 

    <Page id="employeeMasterPage" backgroundDesign="Solid"

If I use Type="DetailAndActive" and detailPress="onSelect" I'm able to trigger right method. But I need to use Type="Active". Therefore I tried to fire press="onSelect".

Do I have to add a controller to the fragment for using these methods?

Unfortunateley, there is no error or something else in the developer console of the browser.

The methods are even registered on the object.