Konrad Radinger
Top achievements
Rank 1
Konrad Radinger
asked on 09 Aug 2009, 07:20 PM
Hi,
I have a grid with 3 Cols: Player, Team, Points.
When I group to Teams, it sums the point from each player to the team result.
Now i want the best team on the first group and so on.
How can I do that?
Greetings
Konrad
I have a grid with 3 Cols: Player, Team, Points.
When I group to Teams, it sums the point from each player to the team result.
Now i want the best team on the first group and so on.
How can I do that?
Greetings
Konrad
5 Answers, 1 is accepted
0
Hi Konrad Radinger,
Thank you for your question. I am afraid that RadGridView does not support this functionality. We will consider your requirement. Write again if you have other questions.
Kind regards,
Victor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thank you for your question. I am afraid that RadGridView does not support this functionality. We will consider your requirement. Write again if you have other questions.
Kind regards,
Victor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Simeon
Top achievements
Rank 1
Iron
answered on 03 Apr 2016, 09:02 AM
Bump
Is this functionality now available?
0
Hello Simeon,
Thank you for writing.
You can refer to the following help article demonstrating how to sort the group rows: http://docs.telerik.com/devtools/winforms/gridview/grouping/sorting-group-rows
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik
Thank you for writing.
You can refer to the following help article demonstrating how to sort the group rows: http://docs.telerik.com/devtools/winforms/gridview/grouping/sorting-group-rows
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Simeon
Top achievements
Rank 1
Iron
answered on 06 Apr 2016, 08:54 AM
Hi Dess,
Thank you for your replay.
In my post i meant functionality described in first post because it exactly cover my requirements. As you can see in this post there is a grouping by Team (teamname) and want to sort by sum generated for the group by values in another column (points). In other words when i'm grouping by one column i want to use sorting based on aggregated values.
In the help article you mentioned i can implement only sorting by values of grouped column, but not by aggregated values based on another column.
If it is possible this functionality will make the grid very powerful in any case of custom reporting and so on.
Regards,
Simeon
Thank you for your replay.
In my post i meant functionality described in first post because it exactly cover my requirements. As you can see in this post there is a grouping by Team (teamname) and want to sort by sum generated for the group by values in another column (points). In other words when i'm grouping by one column i want to use sorting based on aggregated values.
In the help article you mentioned i can implement only sorting by values of grouped column, but not by aggregated values based on another column.
If it is possible this functionality will make the grid very powerful in any case of custom reporting and so on.
Regards,
Simeon
0
Hello Simeon,
Thank you for writing back.
The custom GroupComparer gives you the opportunity to control how exactly the groups are sorted. You can find below a sample code snippet demonstrating a approach how to sort considering the team points:
Note that this is just an example and it may not cover all possible cases. Feel free to modify it in a way which suits your requirement best.
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik
Thank you for writing back.
The custom GroupComparer gives you the opportunity to control how exactly the groups are sorted. You can find below a sample code snippet demonstrating a approach how to sort considering the team points:
public
Form1()
{
InitializeComponent();
this
.radGridView1.MasterTemplate.GroupComparer =
new
GroupComparer();
List<Player> players =
new
List<Player>();
for
(
int
i = 1; i <= 10; i++)
{
players.Add(
new
Player(
"Player"
+ i,
"Team"
+ i % 3, i - 1));
}
this
.radGridView1.DataSource = players;
this
.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
GroupDescriptor descriptor =
new
GroupDescriptor();
descriptor.GroupNames.Add(
"Team"
, ListSortDirection.Ascending);
descriptor.Aggregates.Add(
"Sum(Points)"
);
descriptor.Format =
"{1} has {2} points."
;
this
.radGridView1.GroupDescriptors.Add(descriptor);
}
public
class
GroupComparer : IComparer<Group<GridViewRowInfo>>
{
public
int
Compare(Group<GridViewRowInfo> x, Group<GridViewRowInfo> y)
{
if
(((
object
[])x.Key).First().ToString().Contains(
"Team"
) && ((
object
[])y.Key).First().ToString().Contains(
"Team"
))
{
decimal
team1Points = 0m;
decimal
team2Points = 0m;
foreach
(GridViewRowInfo r
in
x)
{
team1Points += (
decimal
)r.Cells[
"Points"
].Value;
}
foreach
(GridViewRowInfo r
in
y)
{
team2Points += (
decimal
)r.Cells[
"Points"
].Value;
}
return
team1Points.CompareTo(team2Points);
}
return
x.Key.ToString().CompareTo(y.Key.ToString());
}
}
public
class
Player
{
public
string
PlayerName {
get
;
set
; }
public
string
Team {
get
;
set
; }
public
decimal
Points {
get
;
set
; }
public
Player(
string
playerName,
string
team,
decimal
points)
{
this
.PlayerName = playerName;
this
.Team = team;
this
.Points = points;
}
}
Note that this is just an example and it may not cover all possible cases. Feel free to modify it in a way which suits your requirement best.
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.