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 ?
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 ?
Hello,
Server and Instant Feedback Modes (PLinqServerModeSource in particular) are meant to improve your application performance when working with a large amount of data. They allow you to avoid loading an entire data set at once, which, in cases of large data volumes, significantly slows down application startup and consumes a considerable amount of memory. They also carry out all data shaping operations (sorting, grouping, or filtering), which may slow down your application when they are executed on the server side.
Since the DataTable is already loaded in memory in your application, there is no point to use PLinqServerModeSource as this won't give you any benefits.
So, you can assign the DataTable directly to Grid:
If this isn't suitable, we need to understand your entire scenario to suggest a solution. Would you please describe it in greater detail? A step-by-step description and a couple of images demonstrating the current and expected results would be greatly appreciated.
I look forward to your response.
Hello,
if I can get this working I can setup a GetData method that will fetch about 50 rows at a time, and use that as source for the PLinkServerModeSource
That would allow me to display rows from a datatable with about 900000 rows faster.
So yes, I am looking for a way to improve the performance for showing data in the GridView, but my problem is that the query that produces the resultset is not fixed, it can change depending on users choices on the form.
What I am really looking for is a GridMode property like in the Delphi cxGridView, which works great and does not need to know the table schema. Since that does not exists and there are no plans to develop this, I am experimenting with different approaches.
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:
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 ?
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.