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

Custom columns

9 Answers 152 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alexey
Top achievements
Rank 2
Alexey asked on 15 Oct 2009, 08:47 AM
Hi,

In standard silverlight datagrid it is possible to replace auto generated columns with your own custom columns during OnAutoGeneratingColumn.

Telerik RadGridView also have such events, but replacing of e.Column with instance of my column has no effect.

Also I failed to find any guidelines in documentation how to do it correctly.

Thanks,
Alexey Zakharov.

9 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 15 Oct 2009, 11:38 AM
Hi Alexey,

Fixed immediately and the fix will be part of our upcoming beta (before the end of this week). I've added 2000 Telerik points to your account.

Sincerely yours,
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
Alexey
Top achievements
Rank 2
answered on 15 Oct 2009, 12:00 PM
Won't u include it in q2 night build?
0
Vlad
Telerik team
answered on 16 Oct 2009, 01:16 PM
Hello Alexey,

Indeed this will be included in our latest internal build as well.

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
Alexey
Top achievements
Rank 2
answered on 17 Dec 2009, 07:29 AM
Hi,

I've got a problem while manually setting display index in OnAutoGeneratingColumn event:

I'm using the same grid for displaying data of observablecollection<T>. During grid lifecycle, typeof this observable collection could be changed (ObservableCollection<Product>, ObservableCollection<Customer etc)

I clear all columuns if during OnAutoGeneratingColumn event i've noticed that collection type is changed.

I've get an exception DisplayIndexOutOfRange after another collection is supplied to grid.

Here is the source code of overloaded OnAutoGenerationColumn method:

        protected override void OnAutoGeneratingColumn(GridViewAutoGeneratingColumnEventArgs e) 
        { 
            var defaultColumn = e.Column as GridViewDataColumn; 
             
            Type itemType = (this.ItemsSource as IEnumerable).GetItemType(); 
 
            if (this.currentType != itemType) 
            { 
                this.Columns.Clear(); 
                this.currentType = itemType; 
            } 
 
            PropertyInfo propertyInfo = itemType.GetProperty(defaultColumn.UniqueName); 
            var metadatClass = this.AnnotationsMetadataClassFactory.Create(itemType); 
             
            DataFieldInfo dataFieldInfo = this.DataFieldInfoFactory.CreateFromMetaDataClass(metadatClass, propertyInfo.Name); 
 
            var viewer = dataFieldInfo.Viewer; 
            var editor = dataFieldInfo.Editor; 
 
            if (dataFieldInfo.IsAutoGenerated) 
            { 
                if (viewer != null || editor != null && !dataFieldInfo.IsReadOnly) 
                { 
                    var column = new AutoGridViewColumn(dataFieldInfo) { Header = dataFieldInfo.Name, DisplayIndex = dataFieldInfo.Order }; 
 
                    e.Column = column; 
                } 
            } 
            else 
            { 
                e.Column = null
            } 
            base.OnAutoGeneratingColumn(e); 
        } 




I suspect that this is because the columns are generated in random order that is why order value of column could be more than amount of already generated columns.

For my experiments I'm using last telerik q3 release with SP1.

Thanks,
Alexey


0
Stefan Dobrev
Telerik team
answered on 23 Dec 2009, 08:02 AM
Hi Alexey,

I believe the problem is with the index that came from the metadata generated dataFieldInfo. When you set a DisplayIndex on a column and then add it to the columns collection it should be less than the count of all columns. One solution for this is to update the DisplayIndex to the correct value after all columns are auto generated.

Regards,
Stefan Dobrev
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
Alexey
Top achievements
Rank 2
answered on 23 Dec 2009, 08:38 AM
Since we are using same instance of gridview with observablecolletion of different types (ObservableCollection<Product>, ObservableCollection<Store>) its column count shoud be changed.

May be the source of problem is that column count is not updated after itemsource is changed?
0
Stefan Dobrev
Telerik team
answered on 29 Dec 2009, 07:28 AM
Hi Alexey,

After some debugging with different column display indexes I may have found the problem. The first time when the grid is bound we internally initialize the display indexes after the columns are auto generated. This enables scenarios like setting a display index of let say 3 on the first auto-generated column.

However this is not the case when you change the ItemsSource of the grid. Currently there is a limitation and you cannot set a greater display index than the current count of the columns. For example in the first auto-generated column you can only set display index of 0, for the second - 0 or 1 and so on.

We are currently working on a fix for this issue and it will be available in the latest internal build.

Greetings,
Stefan Dobrev
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
Alexey
Top achievements
Rank 2
answered on 07 Feb 2010, 07:30 AM
I have tried updated Grid from last update to 2009 q3, but grid still has problems with display index validation.
  
Message: System.ArgumentOutOfRangeException: GridViewDataControl_ColumnDisplayIndexOutOfRange VideoUri
Parameter name: displayIndex
   at Telerik.Windows.Controls.GridViewColumnCollectionInternal.ValidateDisplayIndex(GridViewColumn column, Int32 displayIndex, Boolean isAdding)
   at Telerik.Windows.Controls.GridViewColumnCollectionInternal.ValidateDisplayIndex(GridViewColumn column, Int32 displayIndex)
   at Telerik.Windows.Controls.GridViewColumnCollectionInternal.InitializeDisplayIndexMap()
   at Telerik.Windows.Controls.GridView.GridViewDataControl.InitializeDisplayIndex()
   at Telerik.Windows.Controls.GridView.GridViewDataControl.<>c__DisplayClass44.<Bind>b__43()
   at Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(FrameworkElement frameworkElement, Action action)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.Bind(Object newValue)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.OnApplyTemplate()
   at System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)     


0
Stefan Dobrev
Telerik team
answered on 11 Feb 2010, 11:14 AM
Hello Alexey,

I have tried to replicate this using the latest version but everything works fine on my end using the snippet you have provided. It seems I'm missing something from your scenario and your actual data. Can you please open a support ticket and attach your problematic application?

Kind regards,
Stefan Dobrev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Alexey
Top achievements
Rank 2
Answers by
Vlad
Telerik team
Alexey
Top achievements
Rank 2
Stefan Dobrev
Telerik team
Share this question
or