Skip to Content

Check all/uncheck all on button press event in sapui5

Hi Experts,

I have a table for mobile application. Table contains 4 fields for storing business data and one field which is actually check box. Now in table header there is two buttons for check all and unchecked all. I want to check all or unchecked all for corresponding button press. How to write the piece of code to achieve this requirement?

Below is my table with check box and two buttons for checked/unchecked-

Thanks & Regards,

Arindam Samanta.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Apr 24, 2015 at 01:17 PM

    I know it is an old post but,

    i think that the best way select / unselect table (list row) is

    // in your table contruction phase


    // select all items


    // unselect all items


    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 24, 2014 at 06:03 AM

    On Select All, set the enable : true property for all the checkbox. Do the vice-versa for Select None.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Arindam Samanta

      What you're doing is correct! this.getView().byId('cB').setSelected(true); should work fine.

      Maybe, you're overriding the selected property somewhere.

  • Feb 24, 2014 at 06:35 AM

    Hi Arindam,

    Try following on select all button event :

    $('#htmlGeneratedID input:checkbox').each(function() {

    $(this).attr('checked', 'checked');


    Add comment
    10|10000 characters needed characters exceeded

  • Feb 24, 2014 at 11:42 AM

    Hi Experts,

    I have found one solution for the above problem. I don't know whether it is right or wrong approach but it is working as per my requirement.

    The solution is below:


    ("#homePage--cB-homePage--tab-0-CbBg") - this is my id for the check box.

    ("sapMCbMarkChecked") - This is the class for checked.

    So above code is working for select all.

    Now I also need to implement the deselect all. In this case I don't have the reverse solution.

    Could it be possible to deselect all through above approach which I have mentioned in this post?

    Thanks in advanced..


    Arindam Samanta

    Add comment
    10|10000 characters needed characters exceeded

    • not smart long term

      api hides css specifis :

      sap.m.CheckBox.prototype.setSelected = function(bSelected) {'-CbBg').toggleClass("sapMCbMarkChecked", bSelected);

      what if SAP changes name of the style in next release?