DomainDataSource MVVM and editing

6 posts, 1 answers
  1. Andrew
    Andrew avatar
    171 posts
    Member since:
    Jun 2009

    Posted 16 Jun 2011 Link to this post

    I have used your sample code to see if i can get the DomainDataSource to work with MVVM.
    It works like a dream very little code.
    However i would like to allow the user to edit the entities.
    How can i change the code from yoru sample (bellow) to allow for that?

    RabbitDomainContext _context = new RabbitDomainContext();
              
    public ClientsViewModel()
    {
        if (!DesignerProperties.IsInDesignTool)
        {
            EntityQuery<Organisation> getOrganisationQuery = _context.GetOrganisationsQuery();
            _organisations = new QueryableDomainServiceCollectionView<Organisation>(_context, getOrganisationQuery);
            _organisations.PageSize = 25;
            _organisations.AutoLoad = true;
        }
                 
    }
      
    private readonly QueryableDomainServiceCollectionView<Organisation> _organisations;
              
    public IEnumerable Organisations
    {
        get { return _organisations; }
    }
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 16 Jun 2011 Link to this post

    Hello Andrew,

    So what is the exact problem? Why can't you edit? Could you be a little bit more specific? 

    Greetings,
    Ross
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Andrew
    Andrew avatar
    171 posts
    Member since:
    Jun 2009

    Posted 16 Jun 2011 Link to this post

    i am a little bit confused at your question. Perhaps i do not understand how RadDomainDataSource works.
    I asume that i would require a to change my code to something like this to allow for editing:

    private QueryableDomainServiceCollectionView<Organisation> _organisations;
              
            public IEnumerable Organisations
            {
                get { return _organisations; }
                set
                {
                    if (value != _organisations)
                    {
                        _organisations = value;
                        OnPropertyChanged("Organisations");
                    }
                }
            }


    However that gives me an error when i try to assign "_organisations = value"
    Error message is:
    Cannot implicitly convert type 'System.Collections.IEnumerable' to 'Telerik.Windows.Data.QueryableDomainServiceCollectionView<cint.Rabbit.Shell.Web.Models.Organisation>'.
  5. Answer
    Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 16 Jun 2011 Link to this post

    Hi Andrew,

    I am really not sure why you are doing all of this. A collection property that has a setter and raises PropertyChanged is against all design principles of .NET. Also, how is this connected with editing anyway? I am not sure why you are doing this, but take my word and don't do it.

    Please read all of these blog posts before trying to go on. Don't just read them, but download the sample project in each one and examine it carefully in order to understand how the control works:

    The blog post with the CRUD in the title demonstrates how you can edit data.

    After you have covered the blog posts, please read the documentation.

    After reading all of these resources, let us know if you have any specific questions. We will be glad to answer any question as long as it is specific and well informed.  Regards,
    Ross
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Andrew
    Andrew avatar
    171 posts
    Member since:
    Jun 2009

    Posted 16 Jun 2011 Link to this post

    I see, yes that does explain it very well.
    I have not added a dataform and am able to edit the object and submit with very little additional code.
    Thanks

    By the way the CRUD example, there is a problem with the project files. I had to edit the solution file to get it to work. Also files appear to be duplicated; you might want to fix that,

  7. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 19 Jul 2011 Link to this post

    The link to the blog entry on CRUD operations is a dead link.

    Is this supposed to be it?
    http://blogs.telerik.com/silverlightteam/posts/10-12-28/creating-crud-application-with-raddomaindatasource-for-silverlight.aspx


    Nope...that ain't it.    
Back to Top
DevCraft banner