ControlPanelItem without GridViewSelectColumn

3 posts, 1 answers
  1. Heiko
    Heiko avatar
    153 posts
    Member since:
    Oct 2012

    Posted 12 Feb 2015 Link to this post

    If followed the Telerik ControlPanelItem "Column chooser" example. It works perfect, though now I have two entries for the GridViewSelectColumn and GridViewToggleRowDetailsColumn which I don't want to display. Is there a way to remove those from the columns list?
  2. Answer
    Boris
    Admin
    Boris avatar
    276 posts

    Posted 13 Feb 2015 Link to this post

    Hello Neils,

    A possible way to remove the GridViewSelectColumn and GridViewToggleRowDetailsColumn columns from the displayed list in the "Column Chooser" dropdown button is to use a convert. For example you can return another collection that excludes the mentioned columns like so:

    public class ColumnChooserConverter : IValueConverter
        {
            public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
            {
                ObservableCollection<GridViewColumn> otherColumns = new ObservableCollection<GridViewColumn>();
                if (value != null)
                {
                    var columns = value as Telerik.Windows.Controls.GridViewColumnCollection;
                     
                    foreach (var column in columns)
                    {
                        if (!column.GetType().Name.Equals("GridViewToggleRowDetailsColumn") && !column.GetType().Name.Equals("GridViewSelectColumn"))
                        {
                            otherColumns.Add(column);
                        }
                    }
                     
                }
     
                return otherColumns;
            }
     
            public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
            {
                // TODO: Implement this method
                throw new NotImplementedException();
            }
        }

    I hope this helps.

    Regards,
    Boris
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Heiko
    Heiko avatar
    153 posts
    Member since:
    Oct 2012

    Posted 13 Feb 2015 in reply to Boris Link to this post

    Thank you, now I get it...
Back to Top