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

Footer problem

6 Answers 220 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anton Samarin
Top achievements
Rank 1
Anton Samarin asked on 22 Sep 2009, 11:02 AM
Hi. Use your control 2009.2.813.35. 
When i add for some column textblock (for example) in footer and make Binding on some property from DataContext sometime get error 'Cannot find source for binding with reference' in VisualStudio 'Output'? - This situation happens not always.

Did you face such a problem? how to solve it?

6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 25 Sep 2009, 06:06 AM
Hello Anton,

Can you post an example where this can be reproduced and debugged?

All the best,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Anton Samarin
Top achievements
Rank 1
answered on 25 Sep 2009, 08:44 AM
Hi, Vlad.
I have not permision to adds project.
May be my problem connected with TrialVersion of Telerik. I created test project, added converter for footer value, binding and converters work(response), but data is not show.

Code: Xaml
 <Grid.Resources>
                    <Converter:DecimalFormatConverter x:Key="DecimalFormatConverter"></Converter:DecimalFormatConverter>
                </Grid.Resources>
                    <telerik:RadGridView Grid.Column="0" Grid.Row="0" ItemsSource="{Binding TestItemList}" ShowColumnFooters="True" Name="radGridViewSelection" AutoGenerateColumns="False" >
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn UniqueName="StringColumn" HeaderText="StringColumn" >
                    <telerik:GridViewDataColumn.Footer>
                        <StackPanel>
                            <TextBlock Text="Sum: "/>
                            <TextBlock Text="{Binding SColumn, Converter={StaticResource DecimalFormatConverter}}"/>
                        </StackPanel>
                    </telerik:GridViewDataColumn.Footer>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn UniqueName="NullableIntColumn" HeaderText="NullableIntColumn" >
                    <telerik:GridViewDataColumn.Footer>
                        <StackPanel>
                            <TextBlock Text="Sum: "/>
                            <TextBlock Text="{Binding NColumn, Converter={StaticResource DecimalFormatConverter}}"/>
                        </StackPanel>
                    </telerik:GridViewDataColumn.Footer>
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

cs:
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
   DataContext = new FooterItem();
            
}

        private void btn_Click(object sender, RoutedEventArgs e)
        {
        }

public class TestListItem
{
public TestListItem(string textColumn, int? nullableIntColumn)
{
this.StringColumn = textColumn;
this.NullableIntColumn = nullableIntColumn;
}

public string StringColumn
{
get;
set;
}

public int? NullableIntColumn
{
get;
set;
}
}

        public class FooterItem
        {
            private string _SColumn;
            private decimal? _NColumn;

            public FooterItem()
            {
               TestItemList = GetObjectData();
               _SColumn = "12345561234345";
                _NColumn = 1234556;
            }

            public string SColumn
            {
                get { return _SColumn; }
                set { _SColumn = value; }
            }

            public decimal? NColumn
            {
                get { return _NColumn; }
                set { _NColumn = value;}
            }

            public ArrayList TestItemList
            {
                get; set;
            }

            private ArrayList GetObjectData()
            {
                var list = new ArrayList();
                list.Add(new TestListItem("Item 1", 1));
                list.Add(new TestListItem("Item 2", null));
                list.Add(new TestListItem("Item 3", 3));
                list.Add(new TestListItem("Item 4", 4));
                list.Add(new TestListItem("Item 5", 4));
                return list;
            }
        }
}

Converter:
public class DecimalFormatConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is decimal?)
            {
                return value;
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
0
Vlad
Telerik team
answered on 01 Oct 2009, 03:23 PM
Hello Anton,

Sorry for the late reply! We will need unfortunately more time to find what is going on this case and once we are ready we will post more info.

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Vlad
Telerik team
answered on 05 Oct 2009, 07:27 AM
Hi Anton,

I've found what may cause the error. This may happen due to the fact that by default DataContext for the  grid footer row (and all child controls) is List<AggregateResult>. Since this object does not have any property called "NColumn" you may get such kind of problems.

Regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Vignesh
Top achievements
Rank 1
answered on 03 Oct 2013, 11:39 AM
Vlad

How to solve this problem, I need to apply red font when the footer value is in negative, I am not using aggregate function, just footer binding
value directly from view model.

Regards
Vignesh 
0
Dimitrina
Telerik team
answered on 04 Oct 2013, 07:27 AM
Hello Vignesh,

You could apply a different color for GridViewFooterCell depending on the value  you are showing for it with an IValueConverter.

For example, you can define the Style similar to:

<Style TargetType="telerik:GridViewFooterCell">
    <Setter Property="Background" Value="{Binding YourViewModelValue, Converter={StaticResource colorConverter}}"/>
</Style>

The converter should return a proper color depending on the value of the "YourViewModelValue" property. For additional information and an example on IValueConverter please check this msdn article.

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Anton Samarin
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Anton Samarin
Top achievements
Rank 1
Vignesh
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or