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

Pivot data, bind header text

9 Answers 37 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 16 Oct 2012, 06:42 PM
I have a need to pivot data, and also to bind the column header to a data item.  Is this possible with the GridView?  As an example, the following grid:

Date        Employee        Hours
1/1/12      John Doe         8.0
1/2/12      John Doe         9.0
1/3/12      John Doe         8.25

Needs to become:

Employee     1/1/12         1/2/12         1/3/12         
John Doe        8.0              9.0              8.25

Can anyone point me to samples, code, etc., which might help accomplish this?  Thanks very much.

9 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 17 Oct 2012, 06:27 AM
Hello Mike,

Could you take a look at this series of examples ? Will RadPivotGrid meet your requirements ?  

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mike
Top achievements
Rank 1
answered on 18 Oct 2012, 03:53 PM
Hello Maya.

Those examples seem to be for a CTP version, which would not be allowed in our application.  And although it does look like there are pivot capabilities, I am looking for something with customization features and the ability to drag/drop columns to pivot.  Syncfusion has this capability in their BI Pivot Grid Grouping Bar demo:
http://silverlight.syncfusion.com/samples/Silverlight/#/Business%20Intelligence%20Edition/PivotGrid/Product%20Showcase/GroupingBar%20Demo

Is there anything within Telerik's suite that could help me accomplish something similar?  We have licenses to both suites, but I am having an issue with the Syncfusion Pivot Grid in my application.  Thanks very much.
0
Vlad
Telerik team
answered on 19 Oct 2012, 06:03 AM
Hello,

 Our Pivot grid is now Beta with just released Q3 2012.

Greetings,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mike
Top achievements
Rank 1
answered on 22 Oct 2012, 10:08 PM
Based on the following data:

Date        Employee        Hours
1/1/12      John Doe         8.0
1/2/12      John Doe         9.0
1/3/12      John Doe         8.25

Needs to become:

Employee     1/1/12         1/2/12         1/3/12         
John Doe        8.0              9.0              8.25

Can you code me a very quick sample which accomplishes this?  Unlike the online samples, I do not need to summarize or provide totals, I just need to take a dataset, display it, and allow the user to decide which pieces of data they want to see as rows or columns.

Thanks very much.
0
Rosen Vladimirov
Telerik team
answered on 24 Oct 2012, 05:56 AM
Hello Mike,

We've prepared a very simple example for your case. We are using LocalDataSource provider and as you can see the XAML is pretty compact and easy for understand. Note that I've used the assemblies from our 2012 Q3 release (you can find trials of them in the project). Also I've set the GrandTotals and SubTotals positions to None, but as  the power of RadPivotGrid is exactly in this feature, you may consider adding them to your application.

Please check the attachment and inform us if it doesn't fit your needs.

Regards,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mike
Top achievements
Rank 1
answered on 24 Oct 2012, 10:53 PM
Hello Rosen.

Thank you for the sample project.  I don't think the Pivot Grid will be able to solve my problem though.  While your sample does seem to accomplish the pivoting, there are cases where the data in the grid would be text, not numbers.  I am simply looking for a way to represent my rows and columns in different formats, and any pivot grids i've seen all seem to do grouping and totaling in the grid cells.  For example, I might have a situation where my data would be:

Date        Employee        DayType
1/1/12      John Doe         5W
                John Smith       10W
1/2/12      John Doe         10W
                John Smith       8V
1/3/12      John Doe         5W
                John Smith       8P

And then needs to become:

Employee     1/1/12         1/2/12         1/3/12         
John Doe        5W              10W              5W
John Smith     10W              8V                8P

Another issue I would have to overcome would be the nesting of collections, my data would not always be flat, although I could do some data manipulation to flatten it.  This is something I would try to avoid though since I try to capitalize on MVVM architecture with bindings and view models.

If you have any suggestions as to how to overcome these hurdles with Telerik controls I'd appreciate any input!  We are currently hold licenses for the entire suite.  Thanks again.
0
Rosen Vladimirov
Telerik team
answered on 25 Oct 2012, 11:23 AM
Hello Mike,

You are correct, the RadPivotGrid is used for grouping and totaling and string data in the cells is not useful for such cases.

You can use RadGridView, but you'll have to add manually all dates as columns and apply Bindings for each of the them to be able to show correct data. I've prepared a simple project to show you my idea, you can find it attached. Also the RadGridView supports hierarchies, more information here

I'm not sure if this solution is suitable for your needs, but this is the best we can offer based on the provided description.

Don't hesitate to contact us if you have any other problems.

Regards,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mike
Top achievements
Rank 1
answered on 26 Oct 2012, 06:10 PM
Hi Rosen.

Thank you for the sample project, that does get me moving in the right direction.  One further question with a slightly more complicated data model...the data model in the sample project we've been discussing looks like:

public class Employee
{
    public string Name { get; set; }
    public List<DateWorkingHours> HoursAndDateType { get; set; }
}

What if that data was a collection contained in a list as well, which is closer to the shape of the data I'd be dealing with
public class Projects
{
    public string ProjectName { get; set; }
    public List<Employee> EmployeeProjects { get; set; }
}

And then I'd need the grid to reflect the ProjectName in a header row above the dates, something like:
                        Project # 1                        Project #2
Employee    1/1/12    1/2/12    1/3/12    1/1/12    1/2/12    1/3/12    1/5/12
John Doe        5W        10W        5W                        5W     10W
John Smith    10W        8V            8P        5W

Is something like that still possible with the RadGridView?  Thanks again.
0
Rosen Vladimirov
Telerik team
answered on 29 Oct 2012, 07:25 PM
Hello Mike,

I'm not sure you'll be able to achieve such output using RadGridView. You can check this article for reference how to create hierarchy using RadGridView. I advise you to check this online demo as it will give you full project with hierarchical data.

Please check the mentioned links and inform me if they doesn't suite your needs.

Regards,
Rosen Vladimirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Mike
Top achievements
Rank 1
Answers by
Maya
Telerik team
Mike
Top achievements
Rank 1
Vlad
Telerik team
Rosen Vladimirov
Telerik team
Share this question
or