Ticket T262703
Visible to All Users

GridView - Large Database & Select All Rows

created 10 years ago

Hi guys,

I have a grid view which binds a large amount of data, which is similar with the grid from this demo http://demos.devexpress.com/MVCxGridViewDemos/DataBinding/DataBindingToLargeDatabase. My problem is that the Select all rows solution is not working for this kind of gridview (http://demos.devexpress.com/MVCxGridViewDemos/Selection/AdvancedSelection). When I click on the checkbox from the header of the grid I end in a very very very long callback.

Even if I use the old solution to select all rows I end with the same very long callback:
settings.CommandColumn.Visible = true;
settings.CommandColumn.ShowSelectCheckbox = true;
settings.CommandColumn.SetHeaderTemplateContent(c =>
{
Html.DevExpress().CheckBox(settingsCB =>
{
    settingsCB.Name = "cbSelectAll";         settingsCB.Properties.ClientSideEvents.CheckedChanged = string.Format("function(s, e) {{ if(s.GetChecked()) {0}.SelectRows(); else {0}.UnselectRows(); }}", settings.Name);         settingsCB.Checked = c.Grid.VisibleRowCount == c.Grid.Selection.Count && c.Grid.VisibleRowCount != 0;     }).GetHtml();
});

The old version of DevExpress was doing this selection in a short period of time. Actually the time spent for the selection was the same time as a regular callback.

I saw the following solution but I don't understand it:
https://www.devexpress.com/Support/Center/Question/Details/T158326.

Best regards,
Florin Gugui.

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

Hello,

Unfortunately, it is impossible to select all rows when the grid is bound to large database. The Implemented mark in the Documentation - GridView - Add a note that the selection of all grid rows via the "SelectAll" check box is not supported in Custom Binding and in Server Mode thread just means that this information was added in the 15.1.2 and 14.2.5 versions of documentation. Should you have any further questions, feel free to contact us.

Updated:

You can set the ASPxGridViewBehaviorSettings.SelectionStoringMode  to " PerfomanceOptimized".

C#
settings.SettingsBehavior.SelectionStoringMode = GridViewSelectionStoringMode.PerformanceOptimized;

In this scenario, when a user selects all rows, the grid begins to add only unselected row keys. In this mode, GridView will operate faster (see the attached video).

    Show previous comments (2)
    NE NE
    Necula Ecaterina 10 years ago

      Hi Artem,
      When using the solution you sent me, the behavior of the gridview is acting as expected. My problem is that I don't know how to handle the unselected items or the selected items on the client side. I mean I can't get the unselected items and I didn't saw some helpful examples. Could you please help me in this case?
      Best regards,
      Florin Gugui.

      NE NE
      Necula Ecaterina 10 years ago

        Hi guys,
        I really need to get the unselected items somehow.
        Florin.

        Artem (DevExpress Support) 10 years ago

          It's possible to implement the following solution:

          1. Handle the client-side ASPxClientGridView.SelectionChanged event. This event is raised each time the grid's selection is changed.
          2. Use the e.isSelected property to indicate if a row was selected/unselected, and the e.visibleIndex property to get a selected/unselected row's visible index.
          3. Then, using a row's visible index, you can get a row key value by using the client-side ASPxClientGridView.GetRowKey method.
          4. You can store these values in a JavaScript array and pass on the server when required.

          Thanks,
          Artem

          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.