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

RadGridView aggregate results in group header show wrong values after group expansion and scrolling

12 Answers 221 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Messir
Top achievements
Rank 1
Messir asked on 30 Jul 2012, 06:49 AM
I use RadGridView in my Silverlight application. I have data grouped and aggregate function results for each group displayed in group headers. When I expand any group and then contract it back, aggregate results are displayed correctly. However, if I expand a group and then SCROLL down, the aggregate results in the groups below the expanded one get shuffled and show values for the other groups.Here's my binding of the TextBox elements in the group header to the aggregate function results:

 <telerik:RadGridView.GroupHeaderTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" 
                                        VerticalAlignment="Center">      
                                   ................................
                                 

                                <TextBlock Name="groupTotal" Text="{Binding AggregateResults[0].Value, BindsDirectlyToSource=True,
                                                          StringFormat=Total: \{0:c\}}"   
                                           FontSize="12"
                                           Foreground="DarkViolet"/>

                                <TextBlock Name="txtSpacer9"
                                           Text="   "
                                           VerticalAlignment="Center"/>


                                <TextBlock Name =" groupApproved" Text="{Binding AggregateResults[1].Value, BindsDirectlyToSource=True,
                                                          StringFormat=Approved: \{0:c\}}" 
                                                  FontSize="12"
                                                  Foreground="Green"/>
                            </StackPanel>
                        </DataTemplate>
                    </telerik:RadGridView.GroupHeaderTemplate>

I create aggregate functions in this method:
 private void AddAggregateFunctions()
        {
            var aggregateFunction = new AggregateFunction<EmployeeExpenseReimbursementObjectdouble>{};

            Func<EmployeeExpenseReimbursementObjectbool> argument = 
                obj => obj.CorpApprovalStatusID == 5 || obj.CorpApprovalStatusID == 8;

            ////////////////////Miles///////////////////////////////////////////////////////////////////////////
            aggregateFunction = new AggregateFunction<EmployeeExpenseReimbursementObjectdouble>
            {
                 AggregationExpression = approvedItems => 
                     approvedItems.Where(argument).Sum(c => c.Miles.ExpenseSubmittedTotal.Value),
                 Caption = "Approved: ",
                 ResultFormatString = "{0:c}"
            };
            gvExpenses.Columns["MilesExpense"].AggregateFunctions.Add(aggregateFunction);
}

and then call it in the window constructor:

AddGgregateFunctions();

Please help me understand what's wrong! I urgently need this working properly!

12 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 30 Jul 2012, 06:51 AM
Hi,

 Can you post more info about the grid version? 

All the best,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Messir
Top achievements
Rank 1
answered on 31 Jul 2012, 06:42 AM
Hi Vlad,

I'm using RadGridView control (Rad Controls for Silverlight, Q1 2011 SP1).

Please advise, how could I resolve this issue. The grid is working wonderfully otherwise, and I just need to get this issue fixed ASAP.
Thanks,

Eugene
0
Maya
Telerik team
answered on 31 Jul 2012, 06:50 AM
Hi Messir,

Could you upgrade to our current official release - Q2 2012 SP1 ? Do you still get the same behavior ?  

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Messir
Top achievements
Rank 1
answered on 31 Jul 2012, 07:29 AM
No, unfortunately my license included upgrades up to November 2011. Any idea why it should happen in my version?
0
Maya
Telerik team
answered on 03 Aug 2012, 11:12 AM
Hello Messir,

We will investigate the case and try to provide an appropriate workaround or a fix. We will let you know once we have more information on the topic.

Regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Pavel Pavlov
Telerik team
answered on 08 Aug 2012, 04:44 PM
Hi Messir,

We are going to fix this for our further versions . However you said you are using an older version so you can not benefit from a fix:

Here is a small workaround I have tested and found working for your case:
Instead of binding to the AggregateResults in the context , you can fetch them from the parent group :

Such as :
<telerik:RadGridView.GroupHeaderTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal"  >
                        <TextBlock  Text="{Binding AggregateResults[0].Value, RelativeSource={RelativeSource AncestorType=telerik:GridViewGroupRow}}"
 
                                   FontSize="12"
                                   Foreground="DarkViolet"/>
                    </StackPanel>
                </DataTemplate>
            </telerik:RadGridView.GroupHeaderTemplate>


Kind regards,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Messir
Top achievements
Rank 1
answered on 28 Nov 2012, 09:46 AM
Hi,

I just upgraded to the trial version of Q3 2012 and it seems like the problem is gone. However, I observe another funny behavior that intereferes with my attempts to finalize the application.

Now, I load the RadGridView, where the group headers have a TextBlock with a name and four checkboxes. Depending on the value of the field in the row business object, chekboxes may be checked or unchecked. If L1 checkbox is checked, the name textbox is green (see attached step 1.jpg, name's Donellan, Paul).

When I expand a group above (Patterson, Barbara), the grid extends down and becomes scrollable. If I scroll down to see Donellan group rows, the group header still has checkboxes correctly checked and the text is green. However, if I collapse the group for Patterson, the Donellan group is no longer green and checkboxes are unchecked, and the group header down below for Bell, Tracy has green text and checked checkboxes, which is wrong. If I reload the page, it is normal again.

So, somehow, when I scroll the grid while a group is extended, the text name and checkbox values travel to another group header. This is similar to previously seen problem with aggregate values, but now group header row controls are involved. Please help me ASAP, as I urgently need to complete this app and I'm considering buying the Q3 2012 version.

Here's the code that colors the name text block and checks the checkboxes in the group header:
 private void txtGroupKey_Loaded(object sender, RoutedEventArgs e)
        {
            TextBlock txtGroupKey = sender as TextBlock;
            GridViewGroupRow row = txtGroupKey.GetVisualParent<GridViewGroupRow>();

            if (row != null && row.Group.ItemCount > 0)
            {
                foreach (AdminExpenseListObject obj in row.Group.Items)
                {
                    if (obj.L1ApprovalStatusID == 5)
                    {
                        SolidColorBrush brush = new SolidColorBrush(Colors.Green);  
                        FontWeight weight = FontWeights.Bold;

                        txtGroupKey.Foreground = brush;
                        txtGroupKey.FontWeight = weight;
                        break;                        
                    }
                }
            }

        }

   private void chkL1All_Loaded(object sender, RoutedEventArgs e)
        {
            CheckBox chk = sender as CheckBox;
            GridViewGroupRow row = chk.GetVisualParent<GridViewGroupRow>();

            chk.IsChecked = true;

            chk.BorderThickness = new Thickness(2.0);

            //Prevent using if not L1 
            if (!WebContext.Current.User.Roles.Contains("Level 1 Supervisor"))
            {
                chk.IsEnabled = false;
            }
           
            ToolTipService.SetToolTip(chk, "Withdraw L1 approval for ALL expenses");

            if (row != null && row.Group.ItemCount > 0)
            {
                foreach (AdminExpenseListObject obj in row.Group.Items)
                {
                    //Prevent approval of a non-submitted report
                    if (obj.EmployeeExpenseProcessingStatusID < 3)
                    {
                        chk.IsChecked = false;
                        chk.IsEnabled = false;
                        ToolTipService.SetToolTip(chk, "This expense report has not been submitted. Approval cannot be done.");
                        break;
                    }
                    else if (obj.L1ApprovalStatusID == 4)
                    {
                        chk.IsChecked = false;
                        ToolTipService.SetToolTip(chk, "Approve ALL expenses");
                        break;
                    }
                    else if (obj.L1ApprovalStatusID == 9)
                    {
                        chk.IsChecked = false;
                        ToolTipService.SetToolTip(chk, "Approval not required");
                        chk.IsEnabled = false;
                        break;
                    }                    
                }               
            }
        }


Thanks a lot




0
Pavel Pavlov
Telerik team
answered on 28 Nov 2012, 10:05 AM
Hi Messir,

By default RadGridView has  scroll virtualization turned on. This means containers ( including group rows ) are being recycled and reused.

You can solve the problem by either turning the virtualization off or by binding the values  instead of setting them in the loaded events of your controls.

Greetings,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Messir
Top achievements
Rank 1
answered on 29 Nov 2012, 05:36 AM
Hi,

How do I turn off scroll virtualization?

Thanks

0
Messir
Top achievements
Rank 1
answered on 29 Nov 2012, 05:51 AM
Hi,

I disabled EnableRowVirtualization and EnableColumnVirtualization, and the problem is gone if I expand one group, but it's still there if I expand two groups - then the coloring of the text in the froup header still migrates to the other group header.

How can I best set up text color by binding? My task is to set the text color in the group header green if at least one business object for any row in the group has certain value. How do I best set up group header check box IsChecked status by binding depending on the values of row business objects?

Thanks a lot
0
Messir
Top achievements
Rank 1
answered on 29 Nov 2012, 06:25 AM
Here's how the group header is bound to the group key:

 <telerik:RadGridView.GroupHeaderTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                            <TextBlock Name="txtGroupKey" Text="{Binding Group.Key}"

How would you suggest to add conditional styling (changing text color depending on the values in group rows) ?

Thanks
0
Vlad
Telerik team
answered on 29 Nov 2012, 08:04 AM
Hi,

 You can check this demo for more info about conditional styling of group rows. 

Greetings,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Messir
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Messir
Top achievements
Rank 1
Maya
Telerik team
Pavel Pavlov
Telerik team
Share this question
or