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.
Unfortunately, activation email could not send to your email. Please try again.

Datagridcontrol does not Display Data when Data is loaded with delay

Thread ID:

Created:

Updated:

Platform:

Replies:

117936 Jan 11,2015 01:14 PM Feb 6,2015 12:28 AM WPF 6
loading
Tags: GridTreeControl
SXTrader
Asked On January 11, 2015 01:14 PM

Hello,
I'm new to  the Syncfusion Framework (and also to the WPF at whole). I want to use the DataTreeControl to display a hierarchy of data which will be loaded and updated in a reoccuring interval. But for some reason it doesn't display the data.

Here's a snipped from my MainWindow.xaml

<syncfusion:TabItemExt Name="_tabItemTipps" Header="Tipps">                  
                        <syncfusion:GridTreeControl Name="_treeGrid"
                                            BorderBrush="LightGray"
                                            BorderThickness="0,0.5,0,0"
                                            EnableHotRowMarker="False"
                                            EnableNodeSelection="True"                                                   
                                            ExpandStateAtStartUp="AllNodesExpanded"
                                            ReadOnly="True"
                                            SupportNodeImages="True"
                                            VisualStyle="Metro"
                                            ItemsSource="SoccerMarkets"
                                           >

                            <!--  Code for GridTreeControl Columns  -->
                            <syncfusion:GridTreeControl.Columns>
                                <syncfusion:GridTreeColumn  HeaderText="Nation" MappingName="{Binding RoughCat}"></syncfusion:GridTreeColumn>
                              
                            </syncfusion:GridTreeControl.Columns>
                        </syncfusion:GridTreeControl>

</syncfusion:TabItemExt>

This the snippet from MainWindow.xaml.cs where the DataContext is set:
  public MainWindow()
        {
            DataContext = this;
            InitializeComponent();
            SkinStorage.SetVisualStyle(_tabControl, "Metro");
            _settingsVM = new AppSettingsVM();
          

            _txtBetdaqUser.DataContext = _settingsVM;
            _chkSystemActive.DataContext = _settingsVM;
            _chkInSimulationMode.DataContext = _settingsVM;

            _mechanic = new TippMechanic(_settingsVM);
            _soccerMarketsVM = new SoccerMarketVM();
           
            Task[] tasks = new Task[1];
            tasks[0] = Task.Factory.StartNew(async () => await _mechanic.Init());// _mechanic.Init();
            Task.WaitAll(tasks);
            _soccerMarketsVM.SoccerMarkets = _mechanic.SoccerMarketManager.SoccerMarkets;
            _treeGrid.DataContext = _soccerMarketsVM.SoccerMarkets;
        }

My ViewModel (_soccerMarketsVM) is defined  this way:
 class SoccerMarketVM : ObservableObject
    {
        private ObservableCollection<SoccerMarket> _soccerMarkets;

        public ObservableCollection<SoccerMarket> SoccerMarkets
        {
            get { return _soccerMarkets; }
            set
            {
                if(_soccerMarkets != null)
                    _soccerMarkets.CollectionChanged -= _soccerMarkets_CollectionChanged;
                _soccerMarkets = value;

                _soccerMarkets.CollectionChanged += _soccerMarkets_CollectionChanged;

            }
        }

        public SoccerMarketVM()
        {
            //_soccerMarkets = new ObservableCollection<SoccerMarket>();
            //_soccerMarkets.CollectionChanged += _soccerMarkets_CollectionChanged;
        }

        void _soccerMarkets_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            Console.WriteLine(e.Action.ToString());
        }
    }

The Events for CollectionChanged are fired and I get the Console.Writeline output.
Does anyone see's something wrong here?

Jai Ganesh S [Syncfusion]
Replied On January 14, 2015 06:22 AM

Hi SxTrader,

Thank you for using Syncfusion products.

We have analyzed your query. We have prepared a sample with Time delay to load the items and it can be downloaded from below location,

Sample Link:

http://www.syncfusion.com/downloads/support/directtrac/general/SelfRelational_Data_Binding_Demo1710773112.zip

Please let us know if you need further assistance.

Thank you,

Jai Ganesh S



SXTrader
Replied On January 14, 2015 08:57 AM

Hello Jay Ganesh,
thank you for your support. Unfortunate your sample programm does not solve my problem.
The GUI of the sample is loaded when the time delayed data has finished loading. Actually if the data loading is pushed truely into background I face the same problem: The gui is displayed with an empty gridtreecontrol and the data isn't updated when the creation of the Model data has been finished by the background worker.

I've modified your sample and attached it this thread, so that you can see the issue.

Thanks

Markus

Attachment: SelfRelational_Data_Binding_Demo_32e77799.zip

SXTrader
Replied On January 14, 2015 03:50 PM

Hi,
I've just figured how it works with asynchrones loading and update. I will update the sample application and post it here. So others who have the same issue can have a look.

Saranya CJ [Syncfusion]
Replied On January 22, 2015 11:28 PM

Hi Markus,

Thank you for your update.
We will wait until you send us the sample application. Please let us know if you require any other assistance on this.

Regards,
Saranya



SXTrader
Replied On February 2, 2015 04:38 AM

Hi,
sorry for the delay. I had to do some things in my job first. You can find a working example attached to this post.
The problem seems to be that if the filling or updating of the ObservableCollection is done in background the presentation framework seems not to react on the events.
I've created a second Observable Collection. When the first one is filled or updated it fires an event which is caught by the ViewModel which compares the first Observable Collection with the second one and if neccessary adjust the second one.
It is not the best solution but a working one. A second step which I haven't done in the example project yet is to implement a NotificationObject Interface.

You can easily compare the two behaviours when you change the Binding in the XAML form PersonDetails2 back to PersonDetail or vice versa.



Attachment: SelfRelational_Data_Binding_Demo_357cc2cf.zip

Jai Ganesh S [Syncfusion]
Replied On February 6, 2015 12:28 AM

Hi Markus,

 

Thank you for your update.

 

Please let us know if you require any other assistance.

 

Regards,

Jai Ganesh S


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.

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.

;