We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Columns order

Thread ID:

Created:

Updated:

Platform:

Replies:

116584 Jun 12,2014 10:20 AM UTC Jul 1,2014 12:08 PM UTC WPF 3
loading
Tags: SfDataGrid
Juraj Tomana
Asked On June 12, 2014 10:20 AM UTC

Hi.

When I set AllowDraggingColumns to True, I can reorder Columns. Please advice me, how can I set the original Columns-order?

Thanks.

Regards,
Juraj

Farjana Parveen Ayubb [Syncfusion]
Replied On June 17, 2014 01:19 PM UTC

Hi Juraj,

 

We analyzed your query. Initially you can save the column order before reordering the columns.

Please refer the following code snippet

 

Code Snippet:

Initially you can saving the column by using “this.dataGrid.Columns.ToList();

 

public partial class MainWindow : ChromelessWindow

    {

        public MainWindow()

        {

            InitializeComponent();

            this.dataGrid.Columns.ToList();

        }

    }

 

Regards,

Farjana Parveen A

 


Juraj Tomana
Replied On June 23, 2014 12:41 PM UTC

Hi.

But how to load the saved state? 

I have tried this way:

       GridColumn[] definovaneStlpce = Columns.ToArray();
        Columns columns = new Columns();
        foreach (
          GridColumn gridColumn in definovaneStlpce.OrderBy(s => Array.IndexOf(_savedColumns, s.MappingName)))
          columns.Add(gridColumn);
        Columns = columns;

.. but nothing happened. Maybe it needs to be refreshed (I've tried View.Refresh(), InvalidateVisual(),...).


I have also tried another way:

        Columns.Clear();
        foreach (
          GridColumn gridColumn in definovaneStlpce.OrderBy(s => Array.IndexOf(_savedColumns, s.MappingName)))
          Columns.Add(gridColumn);

.... but following exception was thrown:
System.ArgumentOutOfRangeException occurred
  _HResult=-2146233086
  _message=1 out of range 0 to 0
  HResult=-2146233086
  IsTransient=false
  Message=1 out of range 0 to 0
Parameter name: from
  Source=Syncfusion.SfGrid.WPF
  ParamName=from
  StackTrace:
       at Syncfusion.UI.Xaml.ScrollAxis.DistanceRangeCounterCollection.CheckRange(String paramName, Int32 from, Int32 to, Int32 actualValue)
  InnerException: 


Thanks.
Regards,
Juraj

Farjana Parveen Ayubb [Syncfusion]
Replied On July 1, 2014 12:08 PM UTC

Hi Juraj,

 

Sorry about the inconvenienced caused.

 

We analyzed your query. You can’t able to set the column property directly. You can load the saved column order by clearing the reorder and adding the saved column order.

 

Please refer the following code snippet and sample in the following location:

 

Code Snippet:

 

public List<GridColumn> columns;

        public MainWindow()

        {

            InitializeComponent();

            columns = sfdatagrid.Columns.ToList();

        }

 

        private void Button_Click(object sender, RoutedEventArgs e)

        {

            sfdatagrid.Columns.Clear();

            foreach (GridColumn grid in columns)

            {

                sfdatagrid.Columns.Add(grid);

            }

        }

 

 

 

Regards,

Farjana Parveen A

 


Attachment: SfDataGridReorderingColumns_7708ea1f.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;