Pivot Grid Showing field values that have any data?

2 Answers 9 Views
PivotGrid and PivotFieldList
Mark
Top achievements
Rank 2
Bronze
Bronze
Veteran
Mark asked on 17 May 2024, 08:42 PM

I have data from a table (child) that may or may not contain values from another table (parent).  When I use the data in the pivot grid, I only see the party field values that exist in my child table, I want to be able to see all the values from the parent table

Example

                  Status      ACTIVE          INACTIVE         DISABLED       CANCELED

Positions

FIRST BASE                    1                           0                           0                    0
SECOND BASE               2                           1                            0                    0
SHORT STOP                 0                           0                           0                    0
THIRD BASE                  10                          10                         13                    12

 

Is this at all possible, by just feeding the data to the DataSource of the pivot grid?

 

Thanks

2 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 22 May 2024, 11:23 AM

Hello, Mark,

I am not sure what exactly is happening on your side. You should be able to see the whole data in RadPivotGrid extracted from your data source. Without having the exact setup I cannot determine why you do not see all field values. Is it possible to provide a sample project and demonstrate there the problem that you are facing? Thus, I could be able to inspect it and assist you further.

I am looking forward to your reply. 

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Mark
Top achievements
Rank 2
Bronze
Bronze
Veteran
commented on 28 May 2024, 11:18 AM

Okay, I guess I didn't highlight the issue.  Our Positions column has 4 possible values, but the result set only contains 3 of those possible 4 values.  If you look at the example above, "SHORT STOP" has ZERO (0) for all the statuses, indicating no records in the Data Source.  We can't get that to show up in our pivot grid, and I can understand why, as we don't have any values in our DataSource with that value in it.   The question is, how can we achieve this just by using the raw data from our queries?

We have to make this generic enough for our end users to change out any additional columns that may be in the data source.  I do know a way of doing this by changing the result query to GroupJoin the playerList into the Positions and Statuses lists, and then in the PivotGrid, instead of using the COUNT aggregate, use the SUM on a new field that has a 1 or 0 in it.   But this is not going to be generic for our users to understand.   My guess, this is probably the only solution to this problem but I wanted to reach out to see if there was a way to do that w/out having to change what aggregate expression is used.

Here is my code snippet


public class Positions
{ 
	public int PositionId {get; set;}
	public string Description {get; set;}
}

public class Statuses
{ 
	public int StatusId {get; set;}
	public string Description {get; set;}
}
public class Players
{ 
	public int PlayerId {get; set;}
	public int PositionId {get; set;}
	public int StatusId {get; set;}
}

public class QueryResults
{ 
	public int PlayerId {get; set;}
	public string Positions {get; set;}
	public string Status {get; set;}
}

	List<Positions> Positions = new List<Positions>
	{
		new Positions {PositionId = 1, Description = "FIRST BASE"},
		new Positions {PositionId = 2, Description = "SECOND BASE"},
		new Positions {PositionId = 3, Description = "SHORT STOP"},
		new Positions {PositionId = 4, Description = "THIRD BASE"}
		
	};

	List<Statuses> Statuses = new List<Statuses>
	{
		new Statuses {StatusId = 1, Description = "ACTIVE"},
		new Statuses {StatusId = 2, Description = "INACTIVE"},
		new Statuses {StatusId = 3, Description = "DISABLED"},
		new Statuses {StatusId = 4, Description = "CANCELED"},
	};
	
	
	List<Players> playerList = new List<Players>
	{
		new Players {PlayerId = 1, PositionId = 1, StatusId = 1},
		new Players {PlayerId = 2, PositionId = 2, StatusId = 1},
		new Players {PlayerId = 3, PositionId = 2, StatusId = 1},
		new Players {PlayerId = 4, PositionId = 2, StatusId = 2},
		new Players {PlayerId = 5, PositionId = 4, StatusId = 1},
		new Players {PlayerId = 6, PositionId = 4, StatusId = 1},
		new Players {PlayerId = 7, PositionId = 4, StatusId = 1},
		new Players {PlayerId = 8, PositionId = 4, StatusId = 1},
		new Players {PlayerId = 9, PositionId = 4, StatusId = 1},
		new Players {PlayerId = 10, PositionId = 4, StatusId = 1},
		new Players {PlayerId = 11, PositionId = 4, StatusId = 1},
		new Players {PlayerId = 12, PositionId = 4, StatusId = 1},
		new Players {PlayerId = 13, PositionId = 4, StatusId = 1},
		new Players {PlayerId = 14, PositionId = 4, StatusId = 1},
		new Players {PlayerId = 15, PositionId = 4, StatusId = 2},
		new Players {PlayerId = 16, PositionId = 4, StatusId = 2},
		new Players {PlayerId = 17, PositionId = 4, StatusId = 2},
		new Players {PlayerId = 18, PositionId = 4, StatusId = 2},
		new Players {PlayerId = 19, PositionId = 4, StatusId = 2},
		new Players {PlayerId = 20, PositionId = 4, StatusId = 2},
		new Players {PlayerId = 21, PositionId = 4, StatusId = 2},
		new Players {PlayerId = 22, PositionId = 4, StatusId = 2},
		new Players {PlayerId = 23, PositionId = 4, StatusId = 2},
		new Players {PlayerId = 24, PositionId = 4, StatusId = 2},
		new Players {PlayerId = 25, PositionId = 4, StatusId = 3},
		new Players {PlayerId = 26, PositionId = 4, StatusId = 3},
		new Players {PlayerId = 27, PositionId = 4, StatusId = 3},
		new Players {PlayerId = 28, PositionId = 4, StatusId = 3},
		new Players {PlayerId = 29, PositionId = 4, StatusId = 3},
		new Players {PlayerId = 30, PositionId = 4, StatusId = 3},
		new Players {PlayerId = 31, PositionId = 4, StatusId = 3},
		new Players {PlayerId = 32, PositionId = 4, StatusId = 3},
		new Players {PlayerId = 33, PositionId = 4, StatusId = 3},
		new Players {PlayerId = 34, PositionId = 4, StatusId = 3},
		new Players {PlayerId = 35, PositionId = 4, StatusId = 3},
		new Players {PlayerId = 36, PositionId = 4, StatusId = 3},
		new Players {PlayerId = 37, PositionId = 4, StatusId = 3},
		new Players {PlayerId = 38, PositionId = 4, StatusId = 4},
		new Players {PlayerId = 39, PositionId = 4, StatusId = 4},
		new Players {PlayerId = 40, PositionId = 4, StatusId = 4},
		new Players {PlayerId = 41, PositionId = 4, StatusId = 4},
		new Players {PlayerId = 42, PositionId = 4, StatusId = 4},
		new Players {PlayerId = 43, PositionId = 4, StatusId = 4},
		new Players {PlayerId = 44, PositionId = 4, StatusId = 4},
		new Players {PlayerId = 45, PositionId = 4, StatusId = 4},
		new Players {PlayerId = 46, PositionId = 4, StatusId = 4},
		new Players {PlayerId = 47, PositionId = 4, StatusId = 4},
		new Players {PlayerId = 48, PositionId = 4, StatusId = 4},
		new Players {PlayerId = 49, PositionId = 4, StatusId = 4},
	};
	
	
	List<QueryResults> results = playerList 
		.Join(Statuses,
			pl => pl.StatusId, 
			st => st.StatusId, 
			(pl, st) => new 
				{
					pl.PlayerId, 
					pl.PositionId, 
					Status = st.Description
				})
			.Join(Positions, 
			pl => pl.PositionId, 
			po => po.PositionId, 
			(pl, po) => new QueryResults 
				{
					PlayerId = pl.PlayerId, 
					Positions = po.Description, 
					Status = pl.Status
				})
		.ToList();
Again, thank you for the help.  
0
Nadya | Tech Support Engineer
Telerik team
answered on 31 May 2024, 09:12 AM

Hello, Mark,

Thank you for providing additional information and your classes to demonstrate better the problem that you have. I have managed to reproduce what you described and was able to observe the following result on my end as well. The "SHORT STOP" column is not displayed into pivot grid since it has no data in it although there is a PositionId field in your Players class:

I understand the specifics of this problem and made research if it is possible to plug somewhere but there is no an easy way to show this column without any data. I have also envolved a developer from the team to look into this. In the core implementation of PivotEngine it is necessary to have at least one record or data in a specific column to allow processing items further. For the test purposes, if you change your data in order to have just one player with PositionId = 3, the "SHORT STOP" will appear. I understand that this may not be an option for you since it requires changes in your raw data.

However, it seems that you manage to find some way of doing this by doing SUM on a new field. I am afraid I cannot suggest another suitable solution at this moment so in case you have a working solution for this case, feel free to use it and fulfil your requirements.

I hope this information is useful. If you have any other questions or concerns do not hesitate to write back.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

A brand new ThemeBuilder course was just added to the Virtual Classroom. The training course was designed to help you get started with ThemeBuilder for styling Telerik and Kendo UI components for your applications. You can check it out at https://learn.telerik.com
Tags
PivotGrid and PivotFieldList
Asked by
Mark
Top achievements
Rank 2
Bronze
Bronze
Veteran
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or