Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1180
Self referencing xamDataGrid display column header on wrong level after rebind data source
posted

Hi Team,

We are using XamDataGrid to display multiple levels data. Since we want resize column applys to all levels on the grid, we are using self referencing Height/Margin style as you suggested and it will show column header on top level only. It's working fine until we tried to re-bind the data source. It will show the column header on the wrong level after we expand the row. I've attached an example.

1. Click on "Binding Data Souce" button. Expand the rows, works fine. Column header show only on top level.

2. Click on Click on "Binding Data Souce" button again. Expand the rows, you will find the column header display on the sub level of the row. Then if you collapse the rows, the column headers won't show anymore.

Could you please help us on this?

Thanks,

Xin

XamDataGridSelfReferencingHierarchicalData.zip
  • 27093
    posted

    Hello Xin,

     

    I have just heard back from development and they seem to have found what is causing this issue in your sampe. It turns out that the converter is only binding to the DataContext - the Record in this case. Well it is possible for the DataRecordPresenter to remain associated with the same HeaderRecord but the HeaderRecord's AttachedToRecord changes. Since the Binding is only to the DataContext (the Record in this case) the converter won't be re-evaluated. This can be handled by binding to the AttachedToRecord, e.g. Here is an example that uses a trigger to apply the binding since the AttachedToRecord is only on HeaderRecord and I wanted to avoid binding error notifications in the output window.

    <Style TargetType="{x:Type igDP:DataRecordPresenter}" x:Key="dataRecordPresenterStyle">

        <Style.Triggers>

            <DataTrigger Binding="{Binding Path=RecordType}" Value="HeaderRecord">

                <Setter Property="Height" Value="{Binding Path=AttachedToRecord, Converter={StaticResource heightConverter}}"/>

            </DataTrigger>

        </Style.Triggers>

    </Style>

     

    Also some changes are required in the converter since it should return double.NaN and not Binding.DoNothing since the element could be recycled from collapsed visual to a not collapsed one. e.g.:

    public object Convert(object value_, Type targetType_, object parameter_, CultureInfo culture_)

    {

        var attachedToRecord = value_ as Record;

        if (attachedToRecord == null)

            return Binding.DoNothing;

        return attachedToRecord.ParentRecord != null ? 1 : double.NaN;

    }

     

    Please let me know if I can be of any further assistance on the matter.

  • 27093
    posted

    Hello Xin,

     

    I have been looking into the sample project you have provided and have been trying to fix it using the built-in functionality, however nothing I tried worked. I have forwarded this to our development team for their assessment on the matter. I have logged this in our internal system under ID: 110363 and I have also created a support ticket on your behalf: CAS-89592-RQKLZ2 and have linked the development issue to it, so that you can get automatically updated, when a Service Release containing the fix is available for download. You can get the new version from our website’s “My IG”, “My Keys & Downloads” tags: https://ko.infragistics.com/Membership/Default.aspx?panel=Downloads#Downloads  

     

    You can also monitor the support ticket’s progress through the “My Support Activity” tag: https://ko.infragistics.com/Membership/MySupport.aspx