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

[Solved] AutoGenerateColumns & ItemsSource Issue?

1 Answer 340 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.
Ross
Top achievements
Rank 1
Ross asked on 31 Dec 2008, 08:49 AM
Hi,

I'm setting up a GridView (using your first look example as a starting point), but am binding to a static resource rather than via codebehind as follows:

<telerik:RadGridView x:Name="radGridViewFirstLook" Margin="5"
                                  ItemsSource="{Binding Path=SelectedFolder.Items, Mode=OneWay, Source={StaticResource AdminModelDS}}"
                                  ColumnsWidthMode="Fill" AutoGenerateColumns="False">
    <telerik:RadGridView.Columns>
        <telerikGridView:GridViewDataColumn IsReadOnly="False" HeaderText="Name" UniqueName="Name" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

However, when running this, the AutoGenerateColumns="False" is being ignored and all columns are displayed.  To fix, I need to have the AutoGenerateColumns value set before the ItemsSource...  This doesn't seem correct behaviour and took quite a long time to realise this was an issue.

Can you confirm?

Thanks,
Ross

1 Answer, 1 is accepted

Sort by
0
Accepted
Rosi
Telerik team
answered on 05 Jan 2009, 12:09 PM
Hello Ross,

Yes, you are absolutely right. The issue is caused by a bug in the way we initialize the internal data-related structures of the grid -- setting some properties too early would generate columns for example, and setting AutoGenerateColumns to false later would not affect the already generated columns.

However we will do our best to fix the issue for the official version of the control.

Meanwhile I suggest you set the ItemsSource property of RadGridView for Silverlight in the code-behind. If you use RadGridView for WPF you can also enable the IsAsync property to solve the problem:

telerik:RadGridView x:Name="radGridViewFirstLook" Margin="5" 
                                  ItemsSource="{Binding Path=SelectedFolder.Items,
                                  Mode=OneWay, Source={StaticResource AdminModelDS},
                                  IsAsync=True}"
 
                                  ColumnsWidthMode="Fill" AutoGenerateColumns="False">  
    <telerik:RadGridView.Columns> 
        <telerikGridView:GridViewDataColumn IsReadOnly="False" HeaderText="Name" UniqueName="Name" /> 
    </telerik:RadGridView.Columns> 
</telerik:RadGridView> 
 

Hope this helps.

Your points have been updated for your involvement.

Regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Ross
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Share this question
or