New Posts New Posts RSS Feed: Added Item Not Visible after save
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Added Item Not Visible after save

 Post Reply Post Reply
Author
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Topic: Added Item Not Visible after save
    Posted: 27-Feb-2013 at 6:29pm
This works fine in TempHire, but in my Cocktail project, after a phone number is added, and the save button is invoked, the Phone disappears from the list.

If I put it back into edit mode, it appears again. Or if the refresh button is clicked, it appears.

The item is being saved to the db properly as it shows up fine after the refresh.

I am not seeing what the issue is.

Greg
Back to Top
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Posted: 27-Feb-2013 at 6:50pm
Found the issue: I had not implemented IHasRoot on the PhoneNumber entity so the SyncInterceptor was not syncing it.

Greg
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 27-Feb-2013 at 6:59pm
W/o seeing your code it's gonna be impossible for me to tell. In TempHire the phone numbers are kept in a BindableCollection of StaffingResourcePhoneItemViewModels. During VM initialization, the collection is populated from the phone number navigation property and then the VM listens to the CollectionChanged event of the navigation property to keep the BindableCollection in sync with the navigation property. If you follow the same model, then perhaps you got a bug in the CollectionChanged event handler. Also make sure that you unhook properly from the CollectionChanged event, so you don't have memory leaks and don't react to events from previous entities. The following is the code from TempHire, that keeps the collection in sync.

        private void PhoneNumbersCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.OldItems != null)
            {
                foreach (var item in
                    e.OldItems.Cast<PhoneNumber>().Select(p => PhoneNumbers.First(i => i.Item == p)))
                {
                    PhoneNumbers.Remove(item);
                    item.Dispose();
                }
            }

            if (e.NewItems != null)
                e.NewItems.Cast<PhoneNumber>()
                    .ForEach(p => PhoneNumbers.Add(new StaffingResourcePhoneItemViewModel(p, EditMode)));

            EnsureDelete();
        }
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 27-Feb-2013 at 7:00pm
Originally posted by gregweb

Found the issue: I had not implemented IHasRoot on the PhoneNumber entity so the SyncInterceptor was not syncing it.

Greg

I see. Looks like our posts crossed paths. 
Back to Top
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Posted: 28-Feb-2013 at 8:44am
Thanks Marcel.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down