Ticket T957966
Visible to All Users
Duplicate

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

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

how to use DataTable.DefaultView as datasource for PLinqServerModeSource

created 4 years ago (modified 4 years ago)

I want to populate a GridView with data from a DataTable using PLinqServerModeSource

I can do this

C#
gridControl1.DataSource = new PLinqServerModeSource() { Source = myDataTable.AsEnumerable() };

but it does not show the data in the GridView
Now I have read that this would work if I use myDataTable.DefaultView, so I tried this

C#
gridControl1.DataSource = new PLinqServerModeSource() { Source = masterTable.DefaultView };

but now I get this weird error ** 'enumerable' does not implement IEnumerable<>**

How can I use the DefaultView of a DataTable as source for a PLinqServerModeSource ?

And if that turns out impossible again, then my question is,
how can I use a DataTable as source for PLinqServerModeSource WITHOUT creating a class for the entity, I cannot do that because my query changes in the source depending on choices made by the user

I also tried this

C#
private List<DataRowView> ConvertToStupidList(DataTable table) { List <DataRowView> Result = new List<DataRowView>(); foreach (DataRowView item in table.DefaultView) { Result.Add(item); } return Result; }

and then I did this

C#
gridControl1.DataSource = new PLinqServerModeSource() { Source = ConvertToStupidList(masterTable) };

That brings me really close, now the gridview shows rows with child rows, and in each childrow all the data of the database is present, with headers and all
But how do I get it out of the childrows and into normal rows ?

Clipboard-File-1.png

I need the data you see not in subrows or childrows or however you call it, and not repeated as many times as there are rows in the datatable
How to do that ?

Show previous comments (2)
DevExpress Support Team 4 years ago

    I can setup a GetData method that will fetch about 50 rows at a time, and use that as source for the PLinkServerModeSource

    The main benefit of Server and Instant Feedback Mode Data Sources is that they load data from the server in small portions and carry out all data shaping operations (sorting, grouping, or filtering) on the server side.
    If you load data manually, there is no need to use PLinqServerModeSource or any other Server Mode Data Source. This won't give any benefits as data is already loaded in memory. Instead, assign loaded data to the GridControl.DataSource property directly.

    As far as I understand, you need to execute a query and display its result in the Grid. Since the resulting data set can be very large, you may want to enable Server Mode.
    You also mentioned the following:

    my query changes in the source depending on choices made by the user

    Currently, it is difficult to suggest a precise solution as it isn't entirely clear what result the query returns. Do I understand it correctly that based on choices the result can be a list of objects of one type (for instance, Customer), and when the choices change, it can be a list of objects of another type (for instance, Products)?
    Please describe this point it in greater detail. A step-by-step description and a couple of images demonstrating the current and expected results would be appreciated.

      Hello,

      yes you understood that correct. Based on the choices the user makes the result can be different entities, like customer or products, or even joins with different tables. Anything is possible.

      I have a small sample project where I experiment with data loading, maybe you could add an example here of using this Server and Instant Feedback Mode Data Sources ?

      DevExpress Support Team 4 years ago

        I see you already asked a similar question in your other ticket:
        does the winforms GridView also has something like the GridMode in Delphi ?
        Let's continue our discussion in that ticket.

        We would appreciate it if you avoid asking similar questions in different tickets so that we can address your inquiries in the most efficient manner.

        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.