Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Dataform requirements for add button RSS

28 replies

Last post Jan 12, 2011 06:08 AM by farris_lime

(0)
  • sladapter

    sladapter

    All-Star

    43609 Points

    7910 Posts

    Re: Re: Dataform requirements for add button

    Jul 08, 2010 07:31 PM | LINK

     Do you have InsertAddress function in your Domain Service?

    Sally Xu
    Software Engineer
    Aprimo, Inc

    Please remember to mark the replies as answers if they answered your question
  • cridenour

    cridenour

    Member

    10 Points

    5 Posts

    Re: Re: Re: Dataform requirements for add button

    Jul 08, 2010 08:24 PM | LINK

    I have an InsertBusinessObject which Address is a sub-class of. I found it interesting that DomainServices don't allow you to generate functions / metadata for sub-classes from the EF Model. Is this my issue?
  • sladapter

    sladapter

    All-Star

    43609 Points

    7910 Posts

    Re: Re: Re: Dataform requirements for add button

    Jul 08, 2010 08:28 PM | LINK

    Don't know. Never used sub-class in EM Model myself. Try to manually add an dummy InsertAddress function in your service to see if you can get Add button to work.

     

    Sally Xu
    Software Engineer
    Aprimo, Inc

    Please remember to mark the replies as answers if they answered your question
  • cridenour

    cridenour

    Member

    10 Points

    5 Posts

    Re: Re: Re: Re: Dataform requirements for add button

    Jul 08, 2010 08:32 PM | LINK

    No luck there. Is DataForm an RIA specific control? I ask because maybe it has something to do with the metadata of that class (or potential lack-of).
  • sladapter

    sladapter

    All-Star

    43609 Points

    7910 Posts

    Re: Re: Re: Re: Dataform requirements for add button

    Jul 08, 2010 08:54 PM | LINK

    No, DataForm is not RIA specific. In order for the Add button to be enabled,  you bind a list that implements IEditableCollectionView. This interface has a CanAddNew property. The Add button is enabled when CanAddNew is true.

    So you can put a break point at DomainDataSource.LoadedData event handler to see if DomainDataSource.DataView.CanAddNew is true.  If not, there must be a reason.  The Setter of this property is private, so you can not set it.

    Also Check the YourDomainContext.Address.CanAdd is true of false, because this determines what value in the DomainDataSource.DataView.CanAddNew property.



    Sally Xu
    Software Engineer
    Aprimo, Inc

    Please remember to mark the replies as answers if they answered your question
  • cridenour

    cridenour

    Member

    10 Points

    5 Posts

    Re: Re: Re: Re: Dataform requirements for add button

    Jul 08, 2010 09:14 PM | LINK

    Apparently Chrome has been given me a lot of issues today.  Time to rethink browser choice for Silverlight development (and for posting on these forms - I had no idea there was supposed to be a WYSIWYG editor!)


    Thankfully clearing the cache / switching browser fixed the problem.  I think the application was stuck in the case where I was binding to Data and not DataView - or maybe adding the InsertAddress function did the trick.  I'll be sure to explore more tomorrow. 


    Thanks for all your help. 

  • sladapter

    sladapter

    All-Star

    43609 Points

    7910 Posts

    Re: Re: Re: Re: Dataform requirements for add button

    Jul 08, 2010 09:23 PM | LINK

    Binding to DomainDataSource.Data or DataView should be the same thing. I always bind to DomainDataSource.Data, never had problem.

    Sally Xu
    Software Engineer
    Aprimo, Inc

    Please remember to mark the replies as answers if they answered your question
  • Oscar Agreda

    Oscar Agreda

    Member

    112 Points

    76 Posts

    Re: Re: Re: Re: Dataform requirements for add button

    Aug 22, 2010 04:24 AM | LINK

    Hello,

    I have a very similar problem using a DataForm to Insert data, in my case is for a Related Entity

    I created an entirely  new question becasue the issue is a bit different

    http://forums.silverlight.net/forums/t/197435.asp

    Regards

  • farris_lime

    farris_lime

    Member

    2 Points

    1 Post

    Re: Re: Dataform requirements for add button

    Jan 12, 2011 06:08 AM | LINK

    Your collection items must implement IEditableObject and implement a defailt constructor creating a new instanse of the object(s) you want to edit in the form.

    #region
    
    using System.ComponentModel;
    using GlobalScheduler.App.Helpers;
    using GlobalScheduler.App.UI.Models;
    using GlobalScheduler.WCF.Services.DataContracts;
    
    #endregion
    
    namespace App.UI.UserControls.Admin
    {
        public class PersonEditModel : IEditableObject
        {
            private PersonModel _backup;
            public PersonModel PersonModel { get; internal set; }
    
            #region construction
    
            public PersonEditModel(Person person)
            {
                PersonModel = new PersonModel(person);
            }
    
            public PersonEditModel()
            {
                PersonModel = new PersonModel(new Person());
            }
    
            #endregion
    
            #region IEditableObject Members
    
            public void BeginEdit()
            {
                _backup =
                    new PersonModel(PropertyComparer.CopyPublicPropertiesOfBuiltInType(PersonModel.Person, new Person()));
            }
    
            public void EndEdit()
            {
                //_backup = null;
            }
    
            public void CancelEdit()
            {
                PropertyComparer.CopyPublicPropertiesOfBuiltInType(_backup, PersonModel);
            }
    
            #endregion
        }
    }