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

Custom Style on Aggregate FooterCell

6 Answers 232 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Craig Corbin
Top achievements
Rank 1
Craig Corbin asked on 22 Nov 2010, 10:45 PM
I have a GridView which displays a SumFunction in a FooterCell.  I would like to make the background of the cell red, if the sum is greater that 1.0.

Here is the working code for this particular column...(With the exception of any code which attempts to apply style.)

              <telerik:GridViewComboBoxColumn
                Header="Percent Allocated"
                DataMemberBinding="{Binding PercentAllocated}"
                ItemsSource="{Binding Source={StaticResource DataContextProxy}, Path=DataSource.PercentSelections}">
                <telerik:GridViewComboBoxColumn.AggregateFunctions>
                  <telerikData:SumFunction Caption="Total Allocation: ">
                  </telerikData:SumFunction>
                </telerik:GridViewComboBoxColumn.AggregateFunctions>
                <telerik:GridViewComboBoxColumn.Footer>
                  <Style TargetType="telerik:GridViewFooterCell">
                    <Style.Setters>
                      <Setter Property="Style" Value="{Binding PercentAllocated, Converter={StaticResource DebuggingConverter}}">
                      </Setter>
                    </Style.Setters>
                  </Style>
                </telerik:GridViewComboBoxColumn.Footer>
              </telerik:GridViewComboBoxColumn>
Any help is appreciated.

Craig

6 Answers, 1 is accepted

Sort by
0
Craig Corbin
Top achievements
Rank 1
answered on 23 Nov 2010, 02:52 PM
Anyone?  Do I need to log a ticket to get this answered?
0
Maya
Telerik team
answered on 23 Nov 2010, 03:20 PM
Hello Craig Corbin,

As the footer is an object of its nature, you can handle directly the appropriate values and events as required.You may take a look at our demo demonstrating how to customize the column footers. You may just define a TextBlock in the footer for example and work directly with it.  
Furthermore, in case you aim at customizing the Group footers as well you may directly use the GroupFooterTemplateSelector.
 

Best wishes,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Craig Corbin
Top achievements
Rank 1
answered on 23 Nov 2010, 05:08 PM
Thank You Maya,

I have successfully implemented the basic functions, aggregate and such.

  • So for using the aggregate generated footer....
I need to be able to apply the style conditionally, based on the numeric value of the aggregate result in the footer row. Any value up to 1.0 get's no special style, while any value in excess of 1.0 get's a red background.

How do I access the numeric value of the aggregate function in the footer row?

How do I then apply a red background to the cell containing that aggregate value?

  • For using the textbox formatted footer....
I was able to create a TextBox in the footer, using the demo code, but was unable to work with it directly as you suggest.  How do I get a reference to the textbox in the footer row, read it's numeric value, and then apply a red background to it's parent cell in the footer row?

Either way is acceptable to me...I just need a complete solution for either way.

Thanks from Craig
0
Maya
Telerik team
answered on 29 Nov 2010, 10:40 AM
Hello Craig Corbin,

I am sending you a sample project illustrating a possible approach for achieving the desired functionality.
 

Greetings,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Craig Corbin
Top achievements
Rank 1
answered on 29 Nov 2010, 07:51 PM
Thanks Maya!  I am so much closer to getting this solved!

I should have mentioned earlier, that the target grid is a detail grid that is dynamically generated.  I think becuase of this the "ParentOfType" function is returning null.  I did use your code sample to change the backgroud of the textbox, but still cannot get a reference to the parent StackPanel to change it's background color...

Here is teh code I am currently using.  The commented line is the line where ParentOfType returns null.

    private void OnDetailGridLoaded(object sender, RowLoadedEventArgs e)
    {
      var detailGrid = e.Row.GridViewDataControl as RadGridView;
      if (detailGrid == nullreturn;
      var totalAllocation = (double) (detailGrid.AggregateResults[0]).FormattedValue;
      if (totalAllocation > .75)
      {
        ((StackPanel)detailGrid.Columns[2].Footer).Background = new SolidColorBrush(Colors.Red);
//        (detailGrid.Columns[2].Footer as StackPanel).ParentOfType<GridViewFooterCell>().Background = new SolidColorBrush(Colors.Green);
      }
    }





Can you help?

Thanks from Craig
0
Maya
Telerik team
answered on 02 Dec 2010, 02:19 PM
Hi Craig Corbin,

In order to provide you an appropriate for your exact scenario solution, I would need a bit more information. How do you generate your detail grid ? How do you load your data ? When do you execute the

OnDetailGridLoaded method ? Any relevant details that will help me to simulate your scenario would be valuable. 

All the best,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
GridView
Asked by
Craig Corbin
Top achievements
Rank 1
Answers by
Craig Corbin
Top achievements
Rank 1
Maya
Telerik team
Share this question
or