Kristjan Einarsson
Top achievements
Rank 1
Kristjan Einarsson
asked on 16 Mar 2012, 03:09 PM
HI, I need simular functionality as this example -> http://www.telerik.com/community/forums/silverlight/gridview/show-aggregates-aligned-with-columns.aspx
To explain a bit better, I have 20 - 30 columns and need to aggregate some of them while I am grouping. As well I would like to change the aggregation number as well. I know that there is no "out of the box" way to do this but is there a way ?
Best regards
Kristján
To explain a bit better, I have 20 - 30 columns and need to aggregate some of them while I am grouping. As well I would like to change the aggregation number as well. I know that there is no "out of the box" way to do this but is there a way ?
Best regards
Kristján
12 Answers, 1 is accepted
0
Hello Kristjan,
What do you mean by "I would like to change the aggregation number as well" ?
Greetings,
Pavel Pavlov
the Telerik team
What do you mean by "I would like to change the aggregation number as well" ?
Greetings,
Pavel Pavlov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Kristjan Einarsson
Top achievements
Rank 1
answered on 16 Mar 2012, 03:46 PM
Hi, I can explain a bit better
Lets say I have a grid that is grouped by OrderNo
OrderNo | ProductName | ProductLocation | Quantity | Value |......
+25 | - | - | 100 | 1000 |.......
+26 | - | - | 25 | 965 |.........
And I would like change the aggregated Value of the order, in other instance I might want to change the Quantity or the value.
When I would change the Value I would need to calculate the new Quantity among other values again.
Hope this make my question clearer :) If not I could go into more details.
Best regards
Kristján
Lets say I have a grid that is grouped by OrderNo
OrderNo | ProductName | ProductLocation | Quantity | Value |......
+25 | - | - | 100 | 1000 |.......
+26 | - | - | 25 | 965 |.........
And I would like change the aggregated Value of the order, in other instance I might want to change the Quantity or the value.
When I would change the Value I would need to calculate the new Quantity among other values again.
Hope this make my question clearer :) If not I could go into more details.
Best regards
Kristján
0
Hi Kristjan,
Ok let me see if I understand ..
Normally the aggregate result is represented by a TextBlock. What you need is a TextBox there , so you can enter some value inside and replace the original aggregate result ?
Is that what you are looking for ?
Greetings,
Pavel Pavlov
the Telerik team
Ok let me see if I understand ..
Normally the aggregate result is represented by a TextBlock. What you need is a TextBox there , so you can enter some value inside and replace the original aggregate result ?
Is that what you are looking for ?
Greetings,
Pavel Pavlov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Kristjan Einarsson
Top achievements
Rank 1
answered on 16 Mar 2012, 04:11 PM
Yes that would work I think
0
Kristjan Einarsson
Top achievements
Rank 1
answered on 19 Mar 2012, 02:03 PM
Can you give me an tip how to make the aggregation columns appear in a textbox ?
Best regards
Kristján.
Best regards
Kristján.
0
Hi,
The attached example demonstrates a way to replace the TextBlock showing aggregate result with a TextBox
in the group footers.
Regards,
Pavel Pavlov
the Telerik team
The attached example demonstrates a way to replace the TextBlock showing aggregate result with a TextBox
in the group footers.
Regards,
Pavel Pavlov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Kristjan Einarsson
Top achievements
Rank 1
answered on 22 Mar 2012, 02:21 PM
Thank you for the example Pavlov.
But I was more leaning more into this direction
But when I do it like this I can not seem to edit the textboxes, when I click them I only expand the group.
I managed to get this code to work with the example app from this thread -> http://www.telerik.com/community/forums/wpf/gridview/my-own-aggregatefunction.aspx (from 2008)
Is there a way to get this functionality with newer Telerik Dll's ?
I changed the sample app that you sent me to better fit my needs and attached an screenshot showing the header with textboxes that I cannot edit.
please advice :)
Best regards
Kristján
But I was more leaning more into this direction
<Grid> <Grid.Resources> <Style TargetType="telerik:GridViewAggregateResultCell"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="telerik:GridViewAggregateResultCell"> <Border MaxWidth="200" Height="Auto" BorderThickness="1,1,1,1"> <Border MinWidth="100" Height="Auto" Background="#00FFFFFF" BorderThickness="1,1,1,1"> <StackPanel Orientation="Horizontal"> <TextBlock Margin="5,-2,5,0" Foreground="#FF027BA8" Text="{Binding Caption}" /> <TextBox Margin="5,-2,5,0" Foreground="#FF027BA8" Text="{Binding FormattedValue, Mode=OneWay}" IsEnabled="True" IsReadOnly="False" /> </StackPanel> </Border> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </Grid.Resources> <telerik:RadGridView x:Name="RadGridView1" AutoGenerateColumns="False" ShowGroupFooters="True" > <telerik:RadGridView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding NumberOfTimes}" > <telerik:GridViewDataColumn.AggregateFunctions> <telerik:SumFunction SourceField="NumberOfTimes" /> </telerik:GridViewDataColumn.AggregateFunctions> </telerik:GridViewDataColumn> </telerik:RadGridView.Columns> </telerik:RadGridView></Grid>But when I do it like this I can not seem to edit the textboxes, when I click them I only expand the group.
I managed to get this code to work with the example app from this thread -> http://www.telerik.com/community/forums/wpf/gridview/my-own-aggregatefunction.aspx (from 2008)
Is there a way to get this functionality with newer Telerik Dll's ?
I changed the sample app that you sent me to better fit my needs and attached an screenshot showing the header with textboxes that I cannot edit.
please advice :)
Best regards
Kristján
0
Hi Kristjan,
I am attaching another sample. It demonstrates a bit different technique - tampering with the template of the group header.
Kind regards,
Pavel Pavlov
the Telerik team
I am attaching another sample. It demonstrates a bit different technique - tampering with the template of the group header.
Kind regards,
Pavel Pavlov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Kristjan Einarsson
Top achievements
Rank 1
answered on 02 Apr 2012, 12:40 PM
Hi Pavel,
I have adopted the solution to .NET 4 WPF. but does not work.
It looks correct enough but I am not able to select any texboxes nor change any value.
Thanks again
Kristján
I have adopted the solution to .NET 4 WPF. but does not work.
It looks correct enough but I am not able to select any texboxes nor change any value.
Thanks again
Kristján
0
Hi Kristjan,
I am attaching a small sample targeting WPF. Hope it helps.
Regards,
Pavel Pavlov
the Telerik team
I am attaching a small sample targeting WPF. Hope it helps.
Regards,
Pavel Pavlov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Kristjan Einarsson
Top achievements
Rank 1
answered on 10 Apr 2012, 03:59 PM
Hi again Pavel.
This is more what I am looking for, but it has some problems
This is how I attach the SumFunctions (witch i need to be able to edit)
Can these problems be solved you think.
I am using rather new Telerik release -> 2012.1.326.40
Thanks again
Kristján
This is more what I am looking for, but it has some problems
- If you have more than one aggregate they will display in Vertical mode (even though the stackpanel is set to Horizontal)
- If you have more than one aggregate you cannot use Tab to switch between them unless you explode the group
This is my code
<Grid> <Grid.Resources> <Style TargetType="telerik:GridViewGroupRow" > <Setter Property="ShowHeaderAggregates" Value="False" /> </Style> </Grid.Resources> <telerik:RadGridView x:Name="RadGridView1" AutoGenerateColumns="True" DataLoaded="grid_DataLoaded" > <telerik:RadGridView.GroupHeaderTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Header}" Margin="0,0,10,0" FontWeight="Bold" /> <telerik:AggregateResultsList ItemsSource="{Binding AggregateResults}" > <telerik:AggregateResultsList.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBox Text="{Binding Value, Mode=OneWay}" /> </StackPanel> </DataTemplate> </telerik:AggregateResultsList.ItemTemplate> </telerik:AggregateResultsList> </StackPanel> </DataTemplate> </telerik:RadGridView.GroupHeaderTemplate> </telerik:RadGridView> </Grid>This is how I attach the SumFunctions (witch i need to be able to edit)
private void grid_DataLoaded(object sender, EventArgs e){if (isFirst) { isFirst = false; foreach (GridViewDataColumn col in grid.Columns) { if (col.Header.ToString() == "UnitQty" || col.Header.ToString() == "UnitQtyChg") { SumFunction sum = new SumFunction(); //sum.Caption = "caption: "; sum.SourceFieldType = typeof(double); col.AggregateFunctions.Add(sum); } } } }}Can these problems be solved you think.
I am using rather new Telerik release -> 2012.1.326.40
Thanks again
Kristján
0
Accepted
Hi,
Here is an updated version of the XAML with the aggregate results stacked horizontaly :
The important part is in yellow.
All the best,
Pavel Pavlov
the Telerik team
Here is an updated version of the XAML with the aggregate results stacked horizontaly :
<telerik:RadGridView.GroupHeaderTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Header}" Margin="0,0,10,0" FontWeight="Bold" /> <telerik:AggregateResultsList ItemsSource="{Binding AggregateResults}" > <telerik:AggregateResultsList.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal" /> </ItemsPanelTemplate> </telerik:AggregateResultsList.ItemsPanel> <telerik:AggregateResultsList.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Caption}" /> <TextBox Text="{Binding Value, Mode=OneWay}" /> </StackPanel> </DataTemplate> </telerik:AggregateResultsList.ItemTemplate> </telerik:AggregateResultsList> </StackPanel> </DataTemplate> </telerik:RadGridView.GroupHeaderTemplate>All the best,
Pavel Pavlov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>