Ticket T957010
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

Grid Control - How to implement the pagination functionality

does the winforms GridView also has something like the GridMode in Delphi ?

created 4 years ago (modified 4 years ago)

I am trying to improve the performance on my winforms project, and I wanted to use the same idea as I did in the Delphi projects many years ago.
I remember that in Delphi the gridView had a DataControler property and it had an option so set GridMode = true
This made the loading of the grid already somewhat better, but it disabled the sorting and the filtering.
The filtering could be enable again by some property AutoFilter or something ,and the sorting could be done by manipulating the order by of the query.
But in winforms I cannot find a DataController property. I looked everywhere (I think) but I cannot find the DataController, nor the GridMode property or the AutoFilter property.

How does one do this in the winforms gridview ?

Show previous comments (9)
Sasha (DevExpress Support) 4 years ago

    Hello Guido,

    Thank you for the clarification. Currently, there is no component or feature that would allow one to achieve all these requirements. As I mentioned before, the loading time is not related directly to our components. It's related to the DataSet implementation in .NET. Our Grid works in a similar way as the VCL Grid with GridMode enabled. It loads and displays only visible records as I mentioned earlier.

    Could you please clarify how you populate your DataSet? I am asking since we have the UnboundSource component which is very similar to what you are looking for. It allows you to add required columns and display data dynamically in the UnboundSource.ValueNeeded event handler. However, it also requires you to write code that creates UnboundSource columns and loads data in the UnboundSource.ValueNeeded event handler.

    For your convenience, I've created a small sample project that illustrates how to load data from a data table using UnboundSource.

      Hello Sasha,

      Thank you for the unbound source example.

      I have incorporated the unbound code into my sample project, and attached it
      I also put some code to get the DataRowCount of the GridView, and it seems it is equal to the masterTable.Rows.Count.
      This suggests that the unbound source does loads all rows immediate into the GridView.
      It does however seem to load fast.
      You also state that the GridView works similar as the VCL grid, but there I do see a difference in the DataRowCount and the Rows.Count of the dataset. So I am not sure if this is correct.

      To make sure the loading time in the grid is measured as correct as possible, I load the data into the DataTable just once, and use the same DataTable for every method of filling the GridView. I do see some differences there, especially when using a method for the first time which is important to me off course.

      My masterTable is populated by a SqlDataAdapter that reads a table from my database, you can use any table from your database to test it. My table has 1.222.818 rows in it

      in my test binding is faster using the unbound source, when the recordcount is about 340.000.
      When I use the table with 1.222.818 rows then the standard binding seems faster again, it also works significant faster when filtering/sorting then the unbound source.

      PLinkServerModeSource is faster, but shows not data, only empty rows. I managed to get it to show data and headers and all, but only in a childlevel, not on the mainlevel.

      The PLinqServerModeSource combined with the GetData method is still the fastest by far, but unfortunate the GridView cannot show any content, only empty rows

      You are right that the loading into the datatable takes the most time. Is there a solution for that ? Again I am thinking of Delphi where you could arange loading a small number of records when needed just by setting some properties. Again keep in mind that I have no clue of the query that will be executed, it can be different every time based on the choices made by the user

      Sasha (DevExpress Support) 4 years ago

        Hello Guido,

        Thank you for the clarification.

        You are right that the loading into the datatable takes the most time. Is there a solution for that ?

        The only way to decrease time taken to load data from a data base to the standard DataSet/DataTable is to load less data. Since you "have no clue of the query that will be executed", I am not sure how this can be possible. In any case, this question is not directly related to our components and I recommend that you look for a solution on common programming resources such as Stack Overflow.

        What about our WinForms Data Grid, you can load and show data using one of the following concepts:

        • Load all data and then show it in the Grid (in this case, data loading takes most time).
        • Load data by portions using Server Mode. Since you don't know the query that will be used to load data in advance, it appears that Server Mode is not suitable.

        I already illustrated multiple techniques to load data and show it in the Grid:

        As far as I can see in the attached sample project, you are still using PLinqServerModeSource but it doesn't show data. I mentioned why it happens in my previous messages and illustrated how to use PLinqServerModeSource in your scenario. This approach seems to be not suitable for you. As far as I understand, direct binding to data table and VirtualServerModeSource are not suitable either.

        It appears that the most suitable approach is to use UnboundSource.

        This suggests that the unbound source does loads all rows immediate into the GridView.

        Unbound Source loads data using the UnboundSource.ValueNeeded event.

        When I use the table with 1.222.818 rows then the standard binding seems faster again, it also works significant faster when filtering/sorting then the unbound source.

        I tested your project and loading time with the standard binding is much greater than time to bind the Grid to Unbound Source. See the attached video. Filtering and sorting indeed take more time when you use an unbound source since it needs to load data from all rows in this case. It's not possible to filter all rows without loading them.

        The PLinqServerModeSource combined with the GetData method is still the fastest by far,

        Yes, this approach is the fastest one, however, it requires you to create the correct IEnumerable collection. The standard DataTable doesn't provide such an API.

        Taking this into account, I suggest that you use UnboundSource. You can show less data using the SetRowCount method. As far as I know, VCL Grid doesn't support filtering and sorting when it works in GridMode. Thus, you can disable this functionality as well.

        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.