This is a migrated thread and some comments may be shown as answers.

Dynamic export a GridView to a PivotGrid

4 Answers 77 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Software
Top achievements
Rank 1
Software asked on 07 Jul 2014, 09:42 AM
Hello everyone, 
I try to develop an export of the GridView to a PivotGrid. 
For that I turn the ItemsSource (IEnumerable <object>) of the GridView in a datatable with only the fields corresponding to the columns of the GridView.
It works fine but there is a performance problem when I iterate the source to add one by one the data in the datatable ( iteration + using reflection to get the values of each field ​​ + LoadDataRow in the datatable) 
Do you see an alternative to the use of a datatable? 
For example, a sub-list of my data source? 
thank you in advance for your suggestions... 
Greetings. 
Olivier.

4 Answers, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 07 Jul 2014, 12:57 PM
Hello Olivier,

I'm not sure I fully understand your problem - you can use the same collection as an ItemsSource of RadPivotGrid and RadGridView. I've prepared a sample project to demonstrate one possible approach how you can achieve this and each change in RadGridView will be immediately shown in RadPivotGrid.

In case you want to show only some of the properties, do you know which ones or the users will be able to select which of the properties to be visible. In case you know which properties will be shown in RadGridView and RadPivotFieldList, you can create additional class (for example PivotOrder) and include in it only the properties that you want to be visible. After that you can use LINQ to transfer your items from RadGridView's ItemsSource to RadPivotGrid. Another option is to use Data Annotations  which are supported in both RadGridView and RadPivotGrid, you can find more information about them in our online help.

Could you share more details on your scenario, so we'll be able to provide better help? I'm looking forward to hearing from you.

Regards,
Rosen Vladimirov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Software
Top achievements
Rank 1
answered on 07 Jul 2014, 01:57 PM
Hello Rosen, 
Thank you for your reply. I'll try to better explain my scenario: 
All GridViews of my project derived from an extended GridView control, they are loaded from IEnumerable<POCO object>, query results of entity framework. 
At screen, the GridView only shows some fields of these objects, as defined columns. 
I wish I could develop in the GridView control, a method that allows to export the contents of the grid (DataMemberBinding, Header Caption Datatype) and not fully POCO objects. 
eg 
List <Customer> lstcust is the source of my GridView 
the columns are defined such that: 
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Nom" /> 
                 <telerik:GridViewDataColumn DataMemberBinding="{Binding Town.Name}" Header="Ville" />
My PivotFieldList will only show 2 fields : "Nom", "Ville"

I created a class to represent my columns: 
     
public class GridViewDataColumnSimple
{
    public TypeData Type {get; set; }
    public String ColumnName {get; set; }
    public String ColumnCaption {get; set; }
 }

and a static function to convert my source datatable from columns

public static DataTable ConvertToDatatable<T>(IEnumerable<GridViewDataColumnSimple> lstcol, IEnumerable<T> data)

The goal is not to define a ViewModel for each GridView my project but to build PivotGrille automatically generically. 

Is Linq To Object can allow me to get my sub-list from a list of items and a list of fields that I want to feed?

I hope I have been a little more clear? ... 
Thank you in advance for your answers


0
Rosen Vladimirov
Telerik team
answered on 09 Jul 2014, 08:15 AM
Hi Olivier,

Thank you for the explanation. I've modified my project to use LINQ and creates new collection based on the one used by RadGridView. Could you take a look at it and inform us if this covers your scenario?

I'm looking forward to hearing from you.

Regards,
Rosen Vladimirov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Software
Top achievements
Rank 1
answered on 11 Jul 2014, 09:48 AM
Hi Rosen, 
Thank you for your reply. It does not match what I wanted but I think I'm going to reconsider my approach to the problem using ViewModels for each GridView and PivotGrid in my project. 
I did not build my application like this because I wanted to develop rather at my custom GridView control's level, a Generic functionality to export as PivotGrid, from the data source of my GridView and columns definitions, without knowing the type of data source of my GridView.
Thank you for having sought a solution with me. 
Greetings. 
Olivier.
Tags
PivotGrid
Asked by
Software
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
Software
Top achievements
Rank 1
Share this question
or