Current filter:
                                You should refresh the page.
                                Support Center
                                1
                                  • Hello there:

                                    I implemented a Gridview with a 'selectOnClick' behavior and using the UnselectRows gave me no problems at all.

                                    For certain reasons i had to switch to a CommandColumn (using the Select checkBox) and from that moment on the UnselectRows stops working.

                                    No errors, client/server and UnselectAllRowsOnPage does work but as the name explains only for the current page. I would like to deselect all the rows within the grid (not only on page)

                                    Any idea?

                                • Hello Alejandro,

                                  Thank you for contacting us. I have tried to reproduce this issue by modifying the online Grid View - Row Selection demo, but failed. The client-side ASPxClientGridView.SelectRows and ASPxClientGridView.UnselectRows methods operate as they should (see the attached video).

                                  [C#]
                                  settings.CommandColumn.Visible = true; settings.CommandColumn.ShowSelectCheckbox = true; settings.CommandColumn.SetHeaderTemplateContent(c => { Html.DevExpress().CheckBox(settingsCheckBox => { settingsCheckBox.Name = "cbSelectAll"; settingsCheckBox.Properties.ClientSideEvents.CheckedChanged = string.Format("function(s, e) {{ if(s.GetChecked()) {0}.SelectRows(); else {0}.UnselectRows(); }}", settings.Name); settingsCheckBox.Checked = c.Grid.VisibleRowCount == c.Grid.Selection.Count; }).Render(); }); settings.SettingsBehavior.AllowSelectByRowClick = true;

                                  Would you please embed this code in your GridView's definition and in your local copy of the mentioned demo, and check how it operates on your side? Do not forget to restore the "Select All" CheckBox state based on the GridView's Selection state. Please keep us informed of your results.

                                  Attached is a sample project.

                                  Regards,
                                  Mike

                                • Alejandro Laborda 02.02.2012

                                  Hi:

                                  Clearly this code works fine, and i found what my problem was:

                                  I have a filter textbox for the grid, so in the "show popup event" I was clearing the filter (ClearFilter()) and just next to this call I was clearing the selection (UnselectRows()). I think, for some reason callbacks/process from ClearFilter() was interrupting the callbacks/process of UnselectRows(). I changed my logic placing these functions on a diff locations and it works!

                                  Thanks for your help! (great work every time I need you guys!)

                                • Hello Alejandro,

                                  Thank you for informing us that the problem has been resolved. We are glad that our assistance was helpful.

                                  Thanks,
                                  Mike

                                You must  log in  or  register  to leave comments

                                1 Solution

                                0

                                A follow-up message:
                                It is necessary to modify the "are all rows selected" criteria (the settingsCheckBox.Checked state) as shown below, because when a filter is applied, the VisibleRowCount property is changed accordingly:

                                [C#]
                                @functions{ bool IsAllSelectedGridView(ASPxGridView gridView){ for (var i = 0; i < gridView.VisibleRowCount; i++) { if (!gridView.Selection.IsRowSelected(i)) return false; } return true; } } @Html.DevExpress().GridView(settings => { ... settings.CommandColumn.SetHeaderTemplateContent(c => { Html.DevExpress().CheckBox(settingsCheckBox => { settingsCheckBox.Name = "cbSelectAll"; settingsCheckBox.Properties.ClientSideEvents.CheckedChanged = string.Format("function(s, e) {{ if(s.GetChecked()) {0}.SelectRows(); else {0}.UnselectRows(); }}", settings.Name); settingsCheckBox.Checked = IsAllSelectedGridView(c.Grid); }).Render(); }); ... settings.Settings.ShowFilterRow = true; }).Bind(Model).GetHtml()
                                • Hendra 01.20.2014

                                  Hi Mike,

                                  I found your solution works great, EXCEPT when the "Grouping" is enabled. VisibleRowCount will also include the group row. This makes the "Select ALL" check box always unchecked.

                                  Is there any way to validate whether the selected row is not a group row?

                                  Thank you,
                                  Hendra

                                • Hendra 01.20.2014

                                  Mike,

                                  I found the code will check the grouping. Here's the updated code:

                                  [C#]
                                  @functions { bool IsAllSelectedGridView(ASPxGridView gridView) { for (var i = 0; i < gridView.VisibleRowCount; i++) { if ((!gridView.IsGroupRow(i)) & (!gridView.Selection.IsRowSelected(i))) return false; } return true; } }
                                  However, I have one more issue when I de-select one of the checkbox in the grid, the "Select ALL" check box should be un-selected. Do I have to provide a custom call back for this? Do you have any example?

                                  Thank you,
                                  Hendra

                                • Hello,

                                  I have created a separate ticket on your behalf to process your inquiry more effectively:
                                  Q465744: GridView - How to handle Select All CheckBox state
                                  Please refer to it for further correspondence.

                                You must  log in  or  register  to leave comments

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners