cancel
Showing results for 
Search instead for 
Did you mean: 

sap.m.CheckBox select event

venkatachala_ck
Active Participant
0 Kudos
7,654

Hi,

I am using sap.m.CheckBox and i want excute piece (function() ) of code after selecting check box

below is my code

<CheckBox xmlns="sap.m"

                                                id="breakdown_id"

                                                selected="false"

                                                visible="true"

                                                enabled="true"

                                                name="break_down"

                                                activeHandling="true"

                                                select="[oController.move]">

                                                </CheckBox>

so how to use select event in xml?

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi,
try
select="functionName"

functionName - function from controller

venkatachala_ck
Active Participant
0 Kudos

thanks for your response but

i tried below code

select= "function(){

move();

}

but it is not working properly..

gill367
Active Contributor
0 Kudos

<CheckBox xmlns="sap.m"

  id="breakdown_id"

     selected="false"

      visible="true"

      enabled="true"

       name="break_down"

      activeHandling="true"

     select="handleSelect">

          </CheckBox>

then in the controller of the view you can write the handler


handleSelect : function(evt) {

               // here your required function.

alert("in check box select handler");
}

Regards,

Sarbjeet

Former Member
0 Kudos

You almost had it.

<CheckBox select="handleSelect" />

and in the controller file, which belongs to the view you are using the CheckBox in, you have the following:

handleSelect : function(oEvent) {

     console.log(oEvent);

}

Refer to SAPUI5 SDK - Demo Kit if you want to know that is in oEvent.

0 Kudos

You don't have to include js code in xml-view. You should add functionName only.

Answers (3)

Answers (3)

VenkyM
Participant
0 Kudos

Hi Venkat,

You can proceed as below,


In view file:

<CheckBox xmlns="sap.m" id="breakdown_id" selected="false"

  visible="true" enabled="true" name="break_down" activeHandling="true"

select="move">

  </CheckBox>

In Controller file:

move: function(){

  alert("checked");

}

Former Member
0 Kudos

Hi Venkata,

Check out the following snippet on JSBIN : http://jsbin.com/tigequmodi/edit?html,js,output

This fiddle is simple example I have created to show how to use XML Views.

Regards

Mayank Jain

sivakumar_mobility
Active Participant
0 Kudos

Hi venkat ,

<CheckBox text="{field}" selected="true" enabled="false" />

you can bind fieds from service use above formats.

If you want to use event use below format

// create a simple CheckBox

var oCB = new sap.ui.commons.CheckBox({

text : 'I want to receive the newsletter',

tooltip : 'Newsletter checkbox',

checked : true,

change : function() {if(oCB.getChecked()){alert('YES')}else{alert('NO')};}

});

With Regards,

siva

venkatachala_ck
Active Participant
0 Kudos

thanks Siva,

i want code in xml for mobile control and i already done in desktop control and js view

NagaPrakashT
Contributor
0 Kudos

Hi Venkat,

Can you please try with this code

View.xml


<CheckBox xmlns="sap.m" text="Demo on Events" select="onSelect" />

View Controller.js


onSelect: function() {

{

   alert("Selected");

  },

Thanks,

Naga

sivakumar_mobility
Active Participant
0 Kudos

Hi Venkatachala,

Please refer below link

https://sapui5.hana.ondemand.com/explored.html#/entity/sap.m.CheckBox/events

Refer Below code.

<Label text="{i18n>addProductLabelDiscontinuedFlag}" />

<CheckBox selected="{newProduct>/Detail/DiscontinuedFlag}" />

I hope it will help you.

sivakumar_mobility
Active Participant
0 Kudos

Hi,

or use below code

<CheckBox id="chkId" text="EXIM \ AÇIK HESAP" />

In controller,

var chk = this.getView().byId("chkId").getSelected();