Databinding in Wisej 3.0. New added rows will not show.

Answered
0
0

Hi,

I have decided to upgrade my projects to Wisej 3.0. But I have found an issue when adding new rows.

I have attached a project to demonstrate the issue.

How to reproduce:

  1. Click on “Get data” button.
  2. Click on “Add a child” button. Nothing seems to happen. But the row is added in the bound data.
  3. Click on “Add a child 2”. Seems to work. And now also the first added row will appear.

 


private void buttonAddAChild_Click(object sender, EventArgs e)
{
// Find selected son
Son son = (Son)sonBindingSource.Current;

son.Childs.Add(DataPortal.FetchChild(“added method 1”, true, “Sir”));
}

private void buttonAddAChild2_Click(object sender, EventArgs e)
{
// Find selected son
Son son = (Son)sonBindingSource.Current;

son.Childs.Add(DataPortal.FetchChild(“added method 2”, true, “Sir”));
sonBindingSource.ResetCurrentItem(); //Should not have to call ResetCurrentItem
}

 

Thanks,

Best regards,
Wilfred

  • You must to post comments
Best Answer
0
0

Hi
This was checked for our development team
Isn’t a Wisej issue, indeed the same sample in winforms has similar result

it’s related for a way that windows(and here CSLA) manage IBindingList

Our team worked in an improvement fot Wisej supporting INofifyCollectionChanged (ObservableCollection) that resolve this
limitation

This will be available on the next release 3.0.13 of Wisej.Net

Regards

 

  • You must to post comments
0
0

We removed the change because it created more problems. We tried the nested CSLA data source directly with WPF and it doesn’t work there either.

IBindingList is part of System.ComponentModel (used by winforms) and it’s more flexible that INotifyCollectionChanged (part of System.Collections.Specialized, and used by WPF with a lot of limitations). Neither of those is specific to Winforms or WPF. Wisej.NET  now supports both. The problem with your sample is using child BindingSource bound to another child BindingSource and then to another that returns a list from another source CSLA (outside of our control) that mixes things. If we try directly with BindingList<> and ObservableCollection<> it works fine. Our DataGridView (not winforms) is an order of magnitude more integrated with server features and data binding than any other web grid.

We also tried Csla.ApplicationContext.PropertyChangedMode = Csla.ApplicationContext.PropertyChangedModes.Xaml and it seems to work also with child of child, etc. Except it still doesn’t work correctly with plain WPF but it’s not our concerm.

  • Wilfred Schønegge
    Thanks Luca, What modifications should I make to the Wisej project to make it work?
  • Luca (ITG)
    Works with Csla.ApplicationContext.PropertyChangedModes.Xaml. If you have it working the same way in WPF send it over.
  • Wilfred Schønegge
    I think it works pretty good with PropertyChangedModes.Xaml as I stated in my last post. But the only problem I have now is “datagridview-focus-jumps-to-the-first-column-after-editing-a-cell”. See link i provided. Is that something that can be fixed?
  • Luca (ITG)
    The problem is that when you edit a property of Knight which is in the Knights collection which is a property of Head, the CSLA framework fires OnChildChanged on Head for the entire Knights list because a property of a child of a child has changed, which fires a ListReset change on the knights collection (which may be a bug in CSLA) and a list reset repopulates (correctly). A potential fix is protected override void OnChildChanged(Csla.Core.ChildChangedEventArgs e) { if (e.PropertyChangedArgs?.PropertyName == “Count”) base.OnChildChanged(e); }. Or maybe there is a CLSA settings not to fire that a list has changed when only a property of an item in the list has changed.
  • You must to post comments
0
0

Hi,

I updated to 3.1.1. Looks like the change is gone?

Anyhow, I would rather be using the WPF databinding model. It’s a more modern/better way of doing databinding compared to the ancient WinForms model.

You can instruct CSLA to do this with this code (It is default value so it is actually not needed):

Csla.ApplicationContext.PropertyChangedMode = Csla.ApplicationContext.PropertyChangedModes.Xaml;

And that seems to be working very fine. No problem when adding or deleting rows.

But there is one problem and the reason why I’m using the Windows forms mode. Csla.ApplicationContext.PropertyChangedModes.Windows
Look in this thread:
https://wisej.com/support/question/datagridview-focus-jumps-to-the-first-column-after-editing-a-cell
I think it is the sole reason why I’m using Csla.ApplicationContext.PropertyChangedModes.Windows

I have provided a new sample code. This time it also contains a WinForms project for reference. The WinForms project has all sorts of problems, including the old WinForms DataGridView that no one should be using anymore. But I hope that Wisej is striving to be a better Choice. Not mimicking all problems in WinForms. I use the grid from DevExpress and it handles the problems.

I have also discovered another problem. When you delete all sons. When the last Son i deleted the cildren do not go away. This is also a problem when using Xaml (WPF) mode.
Best regards,
Wilfred

  • You must to post comments
0
0

Hi Wilfred,
This issue has been fixed in our latest release, 3.0.14.
Regards,
Levie

  • You must to post comments
0
0

Hi

We will check you sample and back to you

regards

  • Wilfred Schønegge
    Hi, Paul. Did you manage to reproduce the issue with the provided sample?
  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.