Custom columns

10 posts, 0 answers
  1. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 15 Oct 2009 Link to this post

    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.
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 15 Oct 2009 Link to this post

    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.
  3. DevCraft banner
  4. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 15 Oct 2009 Link to this post

    Won't u include it in q2 night build?
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 16 Oct 2009 Link to this post

    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.
  6. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 17 Dec 2009 Link to this post

    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


  7. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 23 Dec 2009 Link to this post

    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.
  8. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 23 Dec 2009 Link to this post

    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?
  9. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 29 Dec 2009 Link to this post

    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.
  10. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 07 Feb 2010 Link to this post

    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)     


  11. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 11 Feb 2010 Link to this post

    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.
Back to Top
DevCraft banner