RadGridView Header Binding Issue

5 posts, 0 answers
  1. Sivakumar
    Sivakumar avatar
    8 posts
    Member since:
    Jun 2013

    Posted 26 Jun 2013 Link to this post

    <telerik:GridViewDataColumn DataMemberBinding="{Binding HoursValue}" ColumnGroupName="HoursInfo"

    HeaderCellStyle="{DynamicResource GridViewHeaderRowStyle1}" Width="100" HeaderTextAlignment="Center">

    <telerik:GridViewColumn.Header>

    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">

    <TextBlock Text="Hours "/>

    <TextBlock Text="{Binding ElementName=chkCompYear, Path=Content}"/> // here binding is not working
    or
    <TextBlock Text="{Binding Year}"/> // here binding is not working

    </StackPanel>

    </telerik:GridViewColumn.Header>

    </telerik:GridViewDataColumn>

     

    <CheckBox Name="chkYear" Content="{Binding Year}" // Here it is working


    Model
    -----
    public string Year {get; set;}

     I can able to bind the data to checkbox which is outside the RadGridview, But I cant bind the header.
    Pls help me out to resolve this

     

     

     

  2. Adam
    Adam avatar
    25 posts
    Member since:
    Mar 2012

    Posted 18 Jul 2013 Link to this post


            ------- BUMP -------

    I also have a similar problem...
    <telerik:GridViewDataColumn
        ColumnGroupName="BOO"
        Header="{Binding Path=DataContext.CurrentPeriod, ElementName=ProjectDatesBorder, Converter={StaticResource PeriodHeaderConv}}"
        Width="128" EditTriggers="None"
        ShowDistinctFilters="False" ShowFieldFilters="False" IsFilterable="False" ShowFilterButton="False"
        IsReadOnly="True"
        KeyboardNavigation.IsTabStop="False"
        TextAlignment="Right">
        <!--Header="{Binding Path=DataContext.CurrentPeriod, ElementName=ProjectDatesBorder, Converter={StaticResource PeriodHeaderConv}}"-->
            <telerik:GridViewDataColumn.DataMemberBinding>
                <Binding Path="BookedCostPreviousYP" StringFormat="C" ConverterCulture="en-GB"/>
            </telerik:GridViewDataColumn.DataMemberBinding>
        </telerik:GridViewDataColumn>

    The above works fine,
    however;
    <telerik:GridViewDataColumn
        ColumnGroupName="BOO"
        Width="128" EditTriggers="None"
        ShowDistinctFilters="False" ShowFieldFilters="False" IsFilterable="False" ShowFilterButton="False"
        IsReadOnly="True"
        KeyboardNavigation.IsTabStop="False"
        TextAlignment="Right">
            <telerik:GridViewDataColumn.Header>
                <TextBlock Text="{Binding Path=DataContext.CurrentPeriod, ElementName=ProjectDatesBorder, Converter={StaticResource PeriodHeaderConv}}"
                TextAlignment="Left" TextWrapping="Wrap" FontSize="12" Margin="2 4 5 5"/>
                </telerik:GridViewDataColumn.Header>
                <!--Header="{Binding Path=DataContext.CurrentPeriod, ElementName=ProjectDatesBorder, Converter={StaticResource PeriodHeaderConv}}"-->
                <telerik:GridViewDataColumn.DataMemberBinding>
                    <Binding Path="BookedCostPreviousYP" StringFormat="C" ConverterCulture="en-GB"/>
                </telerik:GridViewDataColumn.DataMemberBinding>
            </telerik:GridViewDataColumn>


    ... this does not - and I require this extra template (which enables the header text to wrap).

    Any help Telerik?
  3. Sivakumar
    Sivakumar avatar
    8 posts
    Member since:
    Jun 2013

    Posted 18 Jul 2013 Link to this post

    Hi Adam,

    Element name binding is solved by setting it in style
    http://www.telerik.com/help/silverlight/gridview-troubleshooting-elementname-binding.html

    Data binding is solved by
    {Binding DataContext.Year, RelativeSource={RelativeSource FindAncestor, 
    AncestorType={x:Type Window}}

    -Sivakumar
  4. Adam
    Adam avatar
    25 posts
    Member since:
    Mar 2012

    Posted 19 Jul 2013 Link to this post


    Thanks for the self-post Sivakumar.

    However, there is nothing wrong with my binding (both should work) - the problem is that I have a custom theme that is applied to the entire RadGridView.
    This means that I either have to re-write that particular element (GridViewHeaderCell) or find some way of getting the GVHC to wrap its contents whilst being bound through the use of the Header property!

    ... and I really want to be lazy on this one.
  5. Adam
    Adam avatar
    25 posts
    Member since:
    Mar 2012

    Posted 19 Jul 2013 Link to this post



    Never mind - I just re-template the header cell.
Back to Top