Ticket T165385
Visible to All Users

MVC GridView - Implement the "Select All" Checkbox inside the SetHeaderTemplateContent

created 10 years ago

I have a MVC Grid View.  Inside the grid view header, I had kept the checkbox.  If I check or uncheck that checkbox, all the rows inside the grid is getting selected.

Where as, after selecting all the rows, If I uncheck any one of the rows, the header checkbox is not getting unchecked.

I had tried using Jquery, It is not working.

For your reference, I have attached a sample, please verify and let me know, how to achieve this functionalty.

Thanks for your help.

Srinivasan Hariharan

Answers approved by DevExpress Support

created 10 years ago

Hello,

In general, we recommend using the built-in "Select All" functionality. It does not require extra code. See the online Select All Rows demo regarding this.
To accomplish this task, you can also use the approach described in the How to implement check boxes with SelectRows and SelectAllRowsOnPage features in a grid's template example. Although it is designed for the web forms technology, the scenario remains the same. See the MVC GridView - "Select All" check box loses its "checked" state ticket for more details.
Let us know if you need further assistance.

    Comments (2)
    SH SH
    Srinivasan Hariharan 3 10 years ago

      Thanks for directing me to the correct example.  I was able to accomplish the Select All Rows.  Please let us know, How to access the selected rows state in the controller?  Is there any predefined methods or how to I get those values in the controller.
      Thanks
      Srinivasan Hariharan

      Lanette (DevExpress Support) 10 years ago

        Hello,

        Thank you for informing me that the information was helpful.
        To access the selected rows state in the controller, perform the following steps:

        1. Get selected rows values via the client-side ASPxClientGridView.GetSelectedFieldValues method;
        2. Pass these values to a Controller via an option described in the Passing Values to Controller Action Through Callbacks help topic.
          See the How to get all GridView selected keys and pass them to a Controller example demonstrating this scenario.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.