Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Yanick Van Barneveld 27 posts 148 karma points
    Nov 03, 2016 @ 12:13
    Yanick Van Barneveld
    0

    UIOMaticListViewField

    Hi,

    I am trying to create a field that has te be shown at the listView. I am creating this field as following:

    [UIOMaticListViewField, Ignore]
    public string MemberName { get { return
    MemberRepository.ngetMember(MemberId).ToString(); } }
    

    This works perfectly at the listView but now, when I want to create a new item is gives the following error (logs are empty):

    Server error: Contact administrator, see log for full details.
    Failed to get scaffold
    

    I can not find any information about this on the internet or in the documentation. Am I missing something?

    Kind regards, Yanick

  • Comment author was deleted

    Nov 03, 2016 @ 12:21

    Hi Yanick,

    Hmm must say I haven't tried it with a getter that actually does anything :p so you might have hit a bug, will try to reproduce and come back to you.

    The scaffold method basically does the following

    public object GetScaffold(Type type)
        {
            var obj = Activator.CreateInstance(type);
    
            var a1 = new ObjectEventArgs(type, obj);
            UIOMaticObjectService.OnScaffoldingObject(a1);
    
            return a1.Object;
        }
    

    So don't see immediatly why it would fail

  • Comment author was deleted

    Nov 03, 2016 @ 12:23

    you MemberRepository when is that initialized ?

  • Yanick Van Barneveld 27 posts 148 karma points
    Nov 03, 2016 @ 12:24
    Yanick Van Barneveld
    0

    It is just a simple class with a static method that looks like this:

    public static Models.Member ngetMember(int id)
        {
            var db = ApplicationContext.Current.DatabaseContext.Database;
            return db.Single<Models.Member>(id);
        }
    
  • Comment author was deleted

    Nov 03, 2016 @ 12:24

    Ok thanks for the details, will give it a go

  • Comment author was deleted

    Nov 03, 2016 @ 12:29

    It's probably because MemberId is still null, so try checking for that before calling the MemberRepository

    Something like

    [UIOMaticListViewField, Ignore]
    public string MemberName { 
      get { 
                if(MemberId == null)
                      return string.Empty;
    
                return MemberRepository.ngetMember(MemberId).ToString(); 
            }
    }
    

    Let me know if that does the trick

  • Comment author was deleted

    Nov 03, 2016 @ 12:34

    And I assume memberId is an int so the check will be

    if(MemberId == 0) return string.Empty;

  • Yanick Van Barneveld 27 posts 148 karma points
    Nov 03, 2016 @ 13:20
    Yanick Van Barneveld
    0

    Awesome that was the trick! You rock Tim!

  • Comment author was deleted

    Nov 03, 2016 @ 13:23

    No prob, hope the project is useful to you :)

Please Sign in or register to post replies

Write your reply to:

Draft