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

RadGridView error

2 Answers 129 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
NS
Top achievements
Rank 1
NS asked on 19 Nov 2008, 01:48 PM
Hi,
I have the following xaml:
<Telerik:RadPage x:Class="SilverlightADTool.ADSearchResults" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
    xmlns:my="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" 
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
    xmlns:Telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
    xmlns:telerik2="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" 
    xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView" 
    xmlns:ms="clr-namespace:System.Windows.Controls;assembly=System.Windows" 
    d:DesignWidth="1024" d:DesignHeight="768" Width="Auto" 
    xmlns:ADToolHelper="clr-namespace:SilverlightADTool.Converter" 
    xmlns:ADTool="clr-namespace:SilverlightADTool" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">  
    <UserControl.Resources> 
        <ADToolHelper:AccountDisabledConverter x:Name="myADDisabled" /> 
        <ADToolHelper:LogonCheckConverter x:Name="myADLogon" /> 
        <ADToolHelper:LogonCheckConverter2 x:Name="myADLogon2" /> 
        <ADToolHelper:ManagerCheckConverter x:Name="managerCheckConverer" /> 
        <ControlTemplate x:Key="LockoutTemplate" TargetType="telerikGridView:GridViewCell">  
            <Image Height="16" Width="16" Source="{Binding Path=LOCKOUT, Converter={StaticResource myADDisabled}}"/>  
        </ControlTemplate> 
        <ControlTemplate x:Key="LogonTemplate" TargetType="telerikGridView:GridViewCell">  
            <Image Height="16" Width="16" Source="{Binding Path=lastLogon, Converter={StaticResource myADLogon2}}" /> 
        </ControlTemplate> 
        <ControlTemplate x:Key="ManagerTemplate" TargetType="telerikGridView:GridViewCell">  
           <Image Height="16" Width="16" Source="{Binding Path=manager, Converter={StaticResource managerCheckConverer}}"/>  
        </ControlTemplate> 
    </UserControl.Resources> 
    <Grid x:Name="LayoutRoot" Background="White">  
        <Grid.RowDefinitions> 
            <RowDefinition Height="38"/>  
            <RowDefinition Height="*" /> 
            <RowDefinition Height="10"/>  
        </Grid.RowDefinitions> 
        <telerik2:RadGridView Name="grdResults2" ColumnsWidthMode="Fill" AutoGenerateColumns="False" Width="Auto" Height="700" Grid.Row="1" Opacity="0" HorizontalAlignment="Stretch">  
            <telerik2:RadGridView.Columns> 
                <telerikGridView:GridViewDataColumn IsReadOnly="True" HeaderText="Domain" DataMemberPath="domainDescription" UniqueName="Domain"  /> 
                <telerikGridView:GridViewDataColumn IsReadOnly="True" HeaderText="Name" DataMemberPath="displayName" UniqueName="Name"  /> 
                <telerikGridView:GridViewDataColumn IsReadOnly="True" HeaderText="SID" DataMemberPath="samacocuntname" UniqueName="SID"  /> 
                <telerikGridView:GridViewDataColumn IsReadOnly="True" HeaderText="OU" DataMemberPath="OUInformation" UniqueName="OU"  /> 
                <telerikGridView:GridViewDataColumn Width="25"  HeaderText="Enabled" UniqueName="Enabled" > 
                    <telerikGridView:GridViewDataColumn.CellStyle> 
                        <Style TargetType="telerikGridView:GridViewCell">  
                            <Setter Property="Template" Value="{StaticResource LockoutTemplate}"/>  
                        </Style> 
                    </telerikGridView:GridViewDataColumn.CellStyle> 
                </telerikGridView:GridViewDataColumn> 
            </telerik2:RadGridView.Columns> 
        </telerik2:RadGridView> 
        <telerik:RadWindow x:Name="window" Width="950" WindowAnimation="OnShow" Height="700" Header="User Information" WindowStartupLocation="CenterScreen" LeftOffset="-150" TopOffset="-50" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">  
            <ADTool:ADUserDetail x:Name="usrCtrlUserDetail" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" /> 
        </telerik:RadWindow> 
        <Button HorizontalAlignment="Left" x:Name="btnBack" Margin="10,8,0,8" Width="69" Content="Back" Visibility="Collapsed" Style="{StaticResource DefaultButtonStyle}"/>  
        <ProgressBar HorizontalAlignment="Left" Margin="10,8,0,8" Width="177" x:Name="progressBar1" IsIndeterminate="True"/>  
    </Grid> 
</Telerik:RadPage> 
 

When I run the application I get the following javascript error:
Sys.InvalidOperationException: ManagedRuntimeError error #4004 in control 'Xaml1': System.NullReferenceException: Object reference not set to an instance of an object. at Telerik.Windows.Controls.GridView.GridView.Scrolling.PhysicalHeightsCache.RefreshItemsPhysicalHeightsCache() at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.get_HeightsCache
() at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.get_ExtentHeight() at Telerik.Windows.Controls.GridView.GridViewScrollViewer.UpdateScrollBars() at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride (Size availableSize) at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single&outHeight)

Removing all the elements and attributes from the RadGridView doesn't solve the problem.

Any thoughts ?
Thanks,
Nicolas

2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 21 Nov 2008, 04:32 PM
Hello NS,

We have a known issue with our CTP RadGridView. When you show the grid but it has not been bound to any data yet, an exception will be thrown.
We are aiming to release a beta version in the middle of December. This issue will be fixed then. If meanwhile that causes problems, I would suggest the following workaround:

In the constructor of your page bind the grid to a fake empty list - something like:

 

public 
 
Page()   
{  
    InitializeComponent();  
    this.testGrid.ItemsSource = new List<string>();   
}  
 
 

 

This will prevent the exception from being thrown.
Then later when real data is available bind the grid to it. You may want to use your List<ADUserInfo> instead of List<string>() in order to have the columns names displayed OK from the  beginning.

Kind regards,

This will prevent the exception from being thrown.Then later when real data is available bind the grid to it. You may want to use your instead Kind regards,
Pavel Pavlov
the Telerik team


Regards,
Pavel Pavlov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
James
Top achievements
Rank 1
answered on 21 Jul 2009, 08:49 PM
Looks like this bug (or something similar) is alive and well in the current binaries. I was getting a bizarre error that had me puzzling for several hours before finding this thread. Adding this.testGrid.ItemsSource = new List<string>();  to the Initialize() of my control fixed the problem. The control that I am using was being created dynamically and then populated with data, so a similar scenario.

James.
Tags
General Discussions
Asked by
NS
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
James
Top achievements
Rank 1
Share this question
or