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

FrozenColumnCount & Reordering

1 Answer 34 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Scott Rakestraw
Top achievements
Rank 1
Scott Rakestraw asked on 14 Dec 2009, 06:05 PM
I am managing the frozen column count outside the grid by letting the user specify the number of columns to freeze.  This works fine but if the user drags a column to before one of the frozen columns the count is then increased.  Is there anyway to prevent it from automatically increasing the frozen column count?  I don't see any event that I can capture for the frozen column count being increased.

1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 17 Dec 2009, 03:24 PM
Hello Scott Rakestraw,

Unfortunately we do not have the appropriate  event , so we need a little hack here .

Here is how we can simulate a frozen columns count  change event:


1. Create an integer  dependency property on the hosting page

2. Bind the FrozenColumncount property of the grid to our property

3. Use the PropertyChanged CallBack of our property to take action on property change.


here is some code I have tested :
public MainPage()
        {
            InitializeComponent();
  
  
            Binding binding = new Binding("FrozenColumnCount");
            binding.Source = this.RadGridView1;
            this.SetBinding(CountProperty, binding);
  
        }
  
  
  
        public int Count
        {
            get { return (int)GetValue(CountProperty); }
            set { SetValue(CountProperty, value); }
        }
  
        public static readonly DependencyProperty CountProperty =
            DependencyProperty.Register("Count", typeof(int), typeof(MainPage), new System.Windows.PropertyMetadata(FrozenCountChanged));
  
  
        static void FrozenCountChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            ((MainPage)sender).RadGridView1.FrozenColumnCount = 1;
        }

This is kind of 'hacky' approach so I believe disabling the UI for freezing would be the better choice. ( e.g.

CanUserFreezeColumns = false)



Regards,
Pavel Pavlov
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.
Tags
GridView
Asked by
Scott Rakestraw
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or