Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
655
Preventing column move in scrollable area
posted

I have a situation where i have the following setup in my data grid:

  • COL1 FIXED LEFT
  • COL2 FIXED LEFT
  • COL3 SCROLLABLE & Fixed (must be first in scrollable area)
  • COLX SCROLLABLE& Movable (Dynamically created columns ...)

The problem i have is that i cannot seem to figure out how to Cancel the move of the column X when it goes to the "first" position in front of COL3. I need to make it so that COL3 is always the first in the scroll area without the user having a chance to change this order.

The user is free to re-order any of the dynamically created X position columns after COL3 and i already have code that saves / reloads their correct position.

Any help to show me how to do this would be appreciated.

Note: I am using the latest release of XamDataGrid rev. 2009, we have not yet upgraded to 2010 release 1.

Parents
No Data
Reply
  • 69686
    Suggested Answer
    posted

    Hello,

    You will not be able to cancel the event, however, you can restore the previous state of the fields easily with the Clear/LoadCustomizations method. for example, you can handle the FieldPositionChanged event and check the moved field. If its ActualPosition.Colulm and name does not meet your condition, you can either load a previous customization or clear the one just made. Here is some sample code for this :

    string layout;

            public MainWindow()

            {

                InitializeComponent();

                xamDataGrid1.Loaded += (s, e) =>

                {

                    layout = xamDataGrid1.SaveCustomizations();

                };

            }

     

            private void xamDataGrid1_FieldPositionChanged(object sender, Infragistics.Windows.DataPresenter.Events.FieldPositionChangedEventArgs e)

            {

                if (e.Field.ActualPosition.Column == 0 && !e.Field.Name.Equals("name"))

                {

                    xamDataGrid1.ClearCustomizations(Infragistics.Windows.DataPresenter.CustomizationType.FieldPosition);

                   // or load the previously saved one xamDataGrid1.LoadCustomizations(layout);

                }

                layout = xamDataGrid1.SaveCustomizations();

            }

    This should keep the "name" field always in the first position.

Children
No Data