Check uncheck all checkboxes of a column from checkbox in header

Posted by: sandyaveas on 2 November 2017, 8:18 pm EST

    • Post Options:
    • Link

    Posted 2 November 2017, 8:18 pm EST

    How can I check and uncheck all checkboxes of a column from checkbox present in header.

  • Posted 6 November 2017, 2:00 am EST

    Hello,

    You can create a custom checkbox cell type for Header cell and handle it’s click event client side to set the checkbox value for whole column. Please refer to the attached sample application.

    Thanks,

    Deepak SharmaSpreadASPHeaderCheckbox.zip

  • Posted 17 April 2018, 8:32 pm EST

    Hi Deepak, My mistake I forgot to mention that I’m using MVC not webforms.

    And the Javascript code which you have written I’ve tried with the same but it’s not working.

    Need:

    In UI I’ve kept 1st column of type checkbox from header checkbox I want check uncheck all the rows and after post the Spread on server side I should get the checked rows.

    Issue:

    1. I’m able to check all the checkboxes with header checkbox but unable to uncheck because after checking the header checkbox, the header checkbox gets unchecked automatically.
    2. I’m not getting the checked value at server side, only first row has checked value rest rows don’t have.
  • Posted 20 April 2018, 2:35 am EST

    Hello,

    1. Since you are working with MVC application, you can set the value of all checkboxes in rows at client side by handling the click of header checkbox. You can use jQuery or JavaScript to do that.

    2. You can get all the selected rows index and save it in an array. You can then send it back to server through ViewBag or Ajax.

    Thanks,

    Deepak Sharma

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels