Copied to clipboard

Flag this post as spam?

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


  • Frank Gillebaard 8 posts 28 karma points
    Apr 11, 2011 @ 12:17
    Frank Gillebaard
    0

    How to get the name of the render control

    Hi,

    I have a little problem and in can’t find the solution in the Umbraco documentation.

    What I want is the name of the render control for a property of a member. See code below. Anyone any idea what method give that data??

            public List<MemberPropertiesEntity> GetMemberProperties()

            {

                /// This function give the detail information for each member.

                List<MemberPropertiesEntity> result = new List<MemberPropertiesEntity>();

                MemberType[] memberTypes = GetAll;

                int outerLoop = 0;

                for (outerLoop = 0; outerLoop < memberTypes.Length; outerLoop++)

                {

                    MemberPropertiesEntity nextResult = new MemberPropertiesEntity();

                    MemberTypeIdentifierEntity nextMember = new MemberTypeIdentifierEntity();

                    nextMember.ID = memberTypes[outerLoop].Id;

                    nextMember.Name = memberTypes[outerLoop].Text;

                    nextResult.memberTypeIdentifier = nextMember;

                    int innerLoop = 0;

                    for (innerLoop = 0; innerLoop < memberTypes[outerLoop].PropertyTypes.Count; innerLoop++)

                    {

                        nextResult.PropertyAlias = memberTypes[outerLoop].PropertyTypes[innerLoop].Alias;

                        nextResult.ContentTypeId = memberTypes[outerLoop].PropertyTypes[innerLoop].ContentTypeId;

                        nextResult.DataTypeName = memberTypes[outerLoop].PropertyTypes[innerLoop].DataTypeDefinition.Text;

                        nextResult.PreValueAsString = library.GetPreValueAsString(memberTypes[outerLoop].PropertyTypes[innerLoop].DataTypeDefinition.Id);

                        nextResult.RenderObjectID = memberTypes[outerLoop].PropertyTypes[innerLoop].DataTypeDefinition.Id;

                        nextResult.RenderObjectName = memberTypes[outerLoop].PropertyTypes[innerLoop].Name;

                        nextResult.SortOrder = memberTypes[outerLoop].PropertyTypes[innerLoop].SortOrder;

                        nextResult.Mandatory = memberTypes[outerLoop].PropertyTypes[innerLoop].Mandatory;

                       

                        // I EXPECT HERE THE NAME OF THE CONTROL AS USED IN UMBRACO. SO VALUES LIKE 'DROPDOWN LIST' OR 'CHECKBOX LIST' OR 'DICTIONARY PICKER'

                        nextResult.RenderObjectName = "??????????????????????";

                       

                       

                       

                        // get detail data

                        XPathNodeIterator preValueRootElementIterator = library.GetPreValues(memberTypes[outerLoop].PropertyTypes[innerLoop].DataTypeDefinition.Id);

                        preValueRootElementIterator.MoveNext();

                        XPathNodeIterator preValueIterator = preValueRootElementIterator.Current.SelectChildren("preValue", "");

                        while (preValueIterator.MoveNext())

                        {

                            MemberTypeIdentifierPropertyDetailDataEntity detailData = new MemberTypeIdentifierPropertyDetailDataEntity();

                            detailData.Value = preValueIterator.Current.Value.ToString();

                            detailData.Attribute = preValueIterator.Current.GetAttribute("id", "");

                            nextResult.DetailData.Add(detailData);

                        }

                    }

                }

                return result;

            }

            private static Guid _objectType = new Guid("9b5416fb-e72f-45a9-a07b-5a9a2709ce43");

            public static MemberType[] GetAll

            {

                get

                {

                    Guid[] Ids = CMSNode.getAllUniquesFromObjectType(_objectType);

     

                    MemberType[] retVal = new MemberType[Ids.Length];

                    for (int i = 0; i < Ids.Length; i++) retVal[i] = new MemberType(Ids[i]);

                    return retVal;

                }

            }

        }

        public class MemberTypeIdentifierPropertyDetailDataEntity

        {

            public string Value { get; set; }

            public string Attribute { get; set; }

        }

        public class MemberTypeIdentifierEntity

        {

            public int ID { get; set; }

            public string Name { get; set; }

        }

        public class MemberPropertiesEntity

        {

            public MemberTypeIdentifierEntity memberTypeIdentifier { get; set; }

            public string PropertyAlias { get; set; }

            public int ContentTypeId { get; set; }

            public string DataTypeName { get; set; }

            public string PreValueAsString { get; set; }

            public int RenderObjectID { get; set; }

            public string RenderObjectName { get; set; }

            public int SortOrder { get; set; }

            public bool Mandatory { get; set; }

            public string RenderControlName { get; set; }

            public List<MemberTypeIdentifierPropertyDetailDataEntity> DetailData { get; set; }

        }

  • Daniel Bardi 927 posts 2562 karma points
    Apr 11, 2011 @ 12:35
    Daniel Bardi
    0

    Try this:

    nextResult.RenderObjectName = memberTypes[outerLoop].PropertyTypes[innerLoop].DataTypeDefinition.DataType.DataTypeName;
  • Frank Gillebaard 8 posts 28 karma points
    Apr 11, 2011 @ 14:47
    Frank Gillebaard
    0

     

    OK Thnks,

     

    That did the job. I needed to change the model a little this is now the code.

     

    gr Frank 

     

    public class SpilterWCFInterface

        {

            public List<MemberPropertiesEntity> GetMemberProperties()

            {

                /// This function give the detail information for each member.

                List<MemberPropertiesEntity> result = new List<MemberPropertiesEntity>();

                MemberType[] memberTypes = GetAll;

                int outerLoop = 0;

                for (outerLoop = 0; outerLoop < memberTypes.Length; outerLoop++)

                {

                    MemberPropertiesEntity nextResult = new MemberPropertiesEntity();

                    MemberTypeIdentifierEntity nextMember = new MemberTypeIdentifierEntity();

                    nextMember.ID = memberTypes[outerLoop].Id;

                    nextMember.Name = memberTypes[outerLoop].Text;

                    nextResult.MemberTypeIdentifier = nextMember;

                    int innerLoop = 0;

                    for (innerLoop = 0; innerLoop < memberTypes[outerLoop].PropertyTypes.Count; innerLoop++)

                    {

                        MemberTypePropertyEntity nextProperty = new MemberTypePropertyEntity();

                        nextProperty.PropertyAlias = memberTypes[outerLoop].PropertyTypes[innerLoop].Alias;

                        nextProperty.ContentTypeId = memberTypes[outerLoop].PropertyTypes[innerLoop].ContentTypeId;

                        nextProperty.DataTypeName = memberTypes[outerLoop].PropertyTypes[innerLoop].DataTypeDefinition.Text;

                        nextProperty.PreValueAsString = library.GetPreValueAsString(memberTypes[outerLoop].PropertyTypes[innerLoop].DataTypeDefinition.Id);

                        nextProperty.RenderObjectID = memberTypes[outerLoop].PropertyTypes[innerLoop].DataTypeDefinition.Id;

                        nextProperty.RenderObjectName = memberTypes[outerLoop].PropertyTypes[innerLoop].Name;

                        nextProperty.SortOrder = memberTypes[outerLoop].PropertyTypes[innerLoop].SortOrder;

                        nextProperty.Mandatory = memberTypes[outerLoop].PropertyTypes[innerLoop].Mandatory;

                        nextProperty.RenderObjectName = memberTypes[outerLoop].PropertyTypes[innerLoop].DataTypeDefinition.DataType.DataTypeName;

                        // get detail data

                        XPathNodeIterator preValueRootElementIterator = library.GetPreValues(memberTypes[outerLoop].PropertyTypes[innerLoop].DataTypeDefinition.Id);

                        preValueRootElementIterator.MoveNext();

                        XPathNodeIterator preValueIterator = preValueRootElementIterator.Current.SelectChildren("preValue", "");

                        while (preValueIterator.MoveNext())

                        {

                            MemberTypeIdentifierPropertyDetailDataEntity detailData = new MemberTypeIdentifierPropertyDetailDataEntity();

                            detailData.Value = preValueIterator.Current.Value.ToString();

                            detailData.Attribute = preValueIterator.Current.GetAttribute("id", "");

                            nextProperty.DetailData.Add(detailData);

                        }

                        nextResult.Property.Add(nextProperty);

                    }

                    result.Add(nextResult);

                }

                return result;

            }

            private static Guid _objectType = new Guid("9b5416fb-e72f-45a9-a07b-5a9a2709ce43");

            public static MemberType[] GetAll

            {

                get

                {

                    Guid[] Ids = CMSNode.getAllUniquesFromObjectType(_objectType);

                    MemberType[] retVal = new MemberType[Ids.Length];

                    for (int i = 0; i < Ids.Length; i++) retVal[i] = new MemberType(Ids[i]);

                    return retVal;

                }

            }

        }

        public class MemberPropertiesEntity

        {

            public MemberPropertiesEntity()

            {

                MemberTypeIdentifier = new MemberTypeIdentifierEntity();        

                Property = new List<MemberTypePropertyEntity>();

            }

            public List<MemberTypePropertyEntity> Property {get; set;}

            public MemberTypeIdentifierEntity MemberTypeIdentifier { get; set; }

        }

        public class MemberTypeIdentifierEntity

        {

            public MemberTypeIdentifierEntity()

            {

                Name = "";

                ID = 0;

            }

            public int ID { get; set; }

            public string Name { get; set; }

        }

        public class MemberTypeIdentifierPropertyDetailDataEntity

        {

            public MemberTypeIdentifierPropertyDetailDataEntity()

            {

                Value = "";

                Attribute = "";

            }

            public string Value { get; set; }

            public string Attribute { get; set; }

        }

        public class MemberTypePropertyEntity

        {

            public MemberTypePropertyEntity()

            {

                DetailData = new List<MemberTypeIdentifierPropertyDetailDataEntity>();

            }

            public string PropertyAlias { get; set; }

            public int ContentTypeId { get; set; }

            public string DataTypeName { get; set; }

            public string PreValueAsString { get; set; }

            public int RenderObjectID { get; set; }

            public string RenderObjectName { get; set; }

            public int SortOrder { get; set; }

            public bool Mandatory { get; set; }

            public string RenderControlName { get; set; }

            public List<MemberTypeIdentifierPropertyDetailDataEntity> DetailData { get; set; }

        }

     

     

  • Daniel Bardi 927 posts 2562 karma points
    Apr 11, 2011 @ 22:04
    Daniel Bardi
    0

    Great news... glad I could help.

    Please mark my post as the solution.

    Good luck!

Please Sign in or register to post replies

Write your reply to:

Draft