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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Adding Columns asynchron

Thread ID:

Created:

Updated:

Platform:

Replies:

144102 Apr 18,2019 01:17 PM UTC Apr 25,2019 12:32 PM UTC WPF 4
loading
Tags: SfDataGrid
Victor Dienstbier
Asked On April 18, 2019 01:17 PM UTC

Hi there,


with your help I managed to get the columns added during runtime. Since I add alot of columns I would like to know if there is an option to update the columns asynchronously?

I have a SfDataGrid in a page. The DataContext is a ViewModel where the ColumnCollection is changed - a lot of columns are beeing added...

<syncfusion:SfDataGrid Name="dtgArbeitsvorrat"
                                           ItemsSource="{Binding Items}"
                                           SelectedItem="{Binding SelectedItem}"
                                           Columns="{Binding ColumnCollection}"
                                           AutoGenerateColumns="False" />

The colum Collection in the ViewModel looks like:

private Syncfusion.UI.Xaml.Grid.Columns _ColumnCollection;
public Syncfusion.UI.Xaml.Grid.Columns ColumnCollection
        {
            get { return _ColumnCollection; }
            set
            {
                _ColumnCollection = value;
                OnPropertyChanged("ColumnCollection");
            }
        }

When I update the columns the UI gets frozen until all columns have been added.

Is there a way to prevent the UI from beeing frozen?


Best wishes!


Victor

Subburaj Pandian Veluchamy [Syncfusion]
Replied On April 19, 2019 12:40 PM UTC

Hi Victor, 
 
Thank you for contacting Syncfusion Support. 
 
Currently we are checking on your requirement, we will validate and let you know the details in two business days April 23, 2019. We appreciate your patience until then. 
 
Regards,  
Subburaj Pandian V  


Dinesh Babu Yadav [Syncfusion]
Replied On April 23, 2019 12:39 PM UTC

Hi Victor, 

Thanks for your patience. 

We have analyzed the reported “UI is frozen when adding columns at runtime”. But we are unable to reproduce the reported issue from our end. Please find tested sample in the below link 

Sample Link: 

If you are still facing the same issue, kindly revert us with the modified sample. It will helps us to investigate further and provide appropriate solution at earliest. 

Regards, 
Dinesh Babu Yadav. 
 


Victor Dienstbier
Replied On April 24, 2019 11:56 AM UTC

Hi,

I tried your solution but that doesn't seem to work for me.

Within my ViewModel I have the columCollection as mentioned.

Now I try the following in the code of the page:

private ViewModel_Formular vm;
        public pagFormular()
        {
            InitializeComponent();

            vm = (ViewModel_Formular)this.DataContext;

            CreateColumnsAsync();
        }

public async void CreateColumnsAsync()
        {
            try
            {
                if (vm.ColumnCollection != null)
                {
                    vm.ColumnCollection.Clear();

                    try
                    {
                        VisualStateManager.GoToState(this.dtgArbeitsvorrat, "Busy", true);

                        dtgArbeitsvorrat.Columns.Suspend();
                        dtgArbeitsvorrat.Columns.Clear();
                        dtgArbeitsvorrat.ClearFilters();

                        await Task.Run(() => SetColumns());

                        dtgArbeitsvorrat.Columns.Resume();
                        dtgArbeitsvorrat.RefreshColumns();
                        VisualStateManager.GoToState(this.dtgArbeitsvorrat, "Normal", true);
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                }
            }
            catch (Exception)
            {

            }
        }

private void SetColumns()
        {
               vm.ColumnCollection.Add(new Syncfusion.UI.Xaml.Grid.GridImageColumn()
               {
                    HeaderText = "Test 1"
               });
               vm.ColumnCollection.Add(new Syncfusion.UI.Xaml.Grid.GridImageColumn()
               {
                    HeaderText = "Test 2"
               });
         }

Is this possible to achiev?

Dinesh Babu Yadav [Syncfusion]
Replied On April 25, 2019 12:32 PM UTC

Hi Victor, 
 
We have analyzed the reported issue based on your provided code snippet. We are able to reproduce the reported issue with considerable amount of delay, only when more number of columns are in view. And you can resolve this by setting UseDrawing as Default for improving the loading performance. Please refer to the below UG link to know more details  
 
UG Link: 
 
If you still want to more performance improvement, please revert us with the below details 
  1. Number of columns that are shown in view area
  2. ColumnSizer that you are using
  3. SfDataGrid configuration details
If possible, kindly share the simple sample, in order to reproduce the exact delay that you are facing at our end. It will helps us to investigate further and provide appropriate solution at earlier. 
 
Regards,
Dinesh Babu Yadav.
 
 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon