Copied to clipboard

Flag this post as spam?

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


  • Manasa 80 posts 201 karma points
    Mar 07, 2014 @ 14:10
    Manasa
    0

    To retrieve generic properties and default properties

    Hi,

     

    Can anyone guide me how to retrieve dgeneric and default properties dynamically?

     

    Thanks

  • Jamie Pollock 174 posts 853 karma points c-trib
    Mar 07, 2014 @ 14:58
    Jamie Pollock
    0

    Hey Manasa,
    Which properties do you need to get and how (XSLT, DynamicNode, IContent, etc)?

    Thanks,
    Jamie

  • Manasa 80 posts 201 karma points
    Mar 09, 2014 @ 07:16
    Manasa
    0

    Hey Jamie,

    I'am new to Umbraco. I would to dynamically fetch ID,created by,creation date etc properties which are dynamically created by Umbraco when a new node is created. I'am able to retrieve custom properties. Would like to know how do I fetch generic properties created by user and default properties that is dynamically generated by Umbraco like ID,created date,template etc., 

    Have created .NET user control. Where i choose a parent node from content picker. On choosing parent node, custom properties are displayed with checkboxes. I would like to add generic and default properties too in this list. I'am using 6.1.6 v.

    Thanks,

    Manasa

     

  • Manasa 80 posts 201 karma points
    Mar 10, 2014 @ 13:08
    Manasa
    0

    Hey Jamie,

    using xml file would be preferable i guess?

     

    Thanks,

    Manasa

  • Jamie Pollock 174 posts 853 karma points c-trib
    Mar 10, 2014 @ 13:11
    Jamie Pollock
    0

    Hi Manasa,
    If you're using a .net user control I would not recommend XML as this is better used with XSLT.

    How are you currently getting the custom properties? Could you share a code snippet?

    Thanks,
    Jamie

  • Manasa 80 posts 201 karma points
    Mar 10, 2014 @ 15:39
    Manasa
    0

    Hey Jamie,

     foreach (Node a in specificNode.Children)

                    {

                        if (a.Children.Count != 0)

             {

                       foreach (Node b in a.ChildrenAsList)

                            {

                                if (x == 0)

                                {

     

                                    if (b.PropertiesAsList.Count != 0)

                                    {

                                        CheckBoxList1.Items.Clear();

     

     

                                        foreach (var c in b.PropertiesAsList)

                                        {

     

                                            CheckBoxList1.Items.Add(c.Alias);

                                            

                                        }

    x=1;

    }

    }

     

  • Jamie Pollock 174 posts 853 karma points c-trib
    Mar 10, 2014 @ 16:16
    Jamie Pollock
    0

    Hi Manasa,
    Thanks for the code! I see you're using Node which is part of the Legacy API. I'd recommend using IPublishedContent instead.

    As you're using a UserControl you should consider inheriting it from UmbracoWebControl (namespace: Umbraco.Web.UI.Controls).

    public partial class YourUserControlName : UmbracoUserControl
    

    This among other things will give you access to this.Umbraco (an UmbracoHelper class).

    Then calling this.Umbraco.TypedContent(yourId) you can get a node as an IPublishedContent node.

    Check out this example below as to how you could do what you do using the new API.

    var specificNode = this.Umbraco.TypedContent(yourId);
    var childrenOfSpecificNode = specificNode.Children;
    
    var hasChildrenOfSpecificNode = childrenOfSpecificNode != null && childrenOfSpecificNode.Any();
    
    if (hasChildrenOfSpecificNode) {
      var firstChildOfSpecificNode = childrenOfSpecificNode.FirstOrDefault();
    
      if (firstChildOfSpecificNode != null) {
        this.CheckBoxList1.Items.Add("Id");
        this.CheckBoxList1.Items.Add("CreateDate");
        this.CheckBoxList1.Items.Add("CreatorName");
    
        foreach (var properties in firstChildOfSpecificNode.Properties) {
          this.CheckBoxList1.Items.Add(properties.Alias);
        }
      }
    }
    

    From what it looks like your code is trying to get the first child of a specific node and loop through its properties. Which is what the code above does. Id, CreateDate & CreatorName are all strongly typed properties of the IPublishedContent class so there isn't a way to get them dynamically. I'd suggest if you wanted to get those you'd have to check for them like so.

    I'm assuming you're working on a PostBack

    var node = this.Umbraco.TypedContent(idOfNodeForUseOnPostBack);
    
    switch (this.CheckBoxList1.SelectedValue) {
      case "Id":
        //get property from strongly typed
        node.Id;
        break;
      case "CreateDate":
        //get property from strongly typed
        node.CreateDate;
      case "CreatorName":
        //get property from strongly typed
        node.CreatorName;
        break;
      default:
        //get property from
        node.GetPropertyValue(this.CheckBoxList1.SelectedValue);
        break;
    }
    

    You could probably improve it further by making Id, CreateDate & CreatorName constants so you don't repeat the strings.

    Does that answer your question?

  • Manasa 80 posts 201 karma points
    Mar 11, 2014 @ 08:33
    Manasa
    0

    Hey Jamie,

    Thanks for the needful help.. Yipee !! it solved my problem.:)

    How can I retrieve values from properties I select from checkboxes and display in gridview? I'am stuck here :(

    1. Initially I select a parent Node.

    2.Secondly, display the properties of child nodes.

    3.Next I select a childnode.

    4.On display button, I wanna display properties selected by user and the grandchildren nodes in gridview.

    I'am stuck in 4th step. Please guide me

     

    Thanks 

    Manasa

  • Jamie Pollock 174 posts 853 karma points c-trib
    Mar 11, 2014 @ 09:38
    Jamie Pollock
    0

    Hey Manasa,
    So as I understand it you want to display only the checked properties of the child node you've selected?

    Or the checked properties of that child node's children?

    Thanks,
    Jamie

  • Manasa 80 posts 201 karma points
    Mar 11, 2014 @ 09:49
    Manasa
    0

    Checked properties of that child node's children - Jamie :)

  • Manasa 80 posts 201 karma points
    Mar 11, 2014 @ 09:54
    Manasa
    0

    Contacts

      A

         Anu

        Angel

      B

        Bharath

        Bargavi

    Here if i select contacts as parent node, I get the properties of Anu. 

    Here user selects properties he want to display.(firstname,ID,lastname)

    Next he has a save button. On click of this button dropdown list with A,B etc is displayed. If user selects A, and clicks on display

    properties(firstname,ID,lastname) along with their values of anu and angel should be displayed in gridview. If user selects B from dropdown, should display bharath and bargavi with their properties selected from dropdownlist.

     

    Thanks

    Manasa

  • Jamie Pollock 174 posts 853 karma points c-trib
    Mar 11, 2014 @ 10:30
    Jamie Pollock
    100

    Sounds like you need a Current Users control which is separate to the users and then it will be used to bind the current users.

    It might be easier do this with a Repeater web control. Because you'll have a varying number of columns.

    so...

    1. Select your display options from the checkbox
    2. Select your children from the current Letter
    3. Upon selecting a letter then show only the fields you want based on your display options

    To display the fields

    1. Loop through each of the children from the Letter node
    2. Cross reference with the display options checkboxlist which fields are currently selected
    3. Each entry in this repeater is a List

    Your list would be a List<List<string>> which seems a bit weird nut right now I can't thing of anything which would allow the degree of flexability...

    Although I'll admit I'm a bit rusty with Web Forms.

    You may also want to check out this link too. Which uses GridViews with dynamic columns.

  • Manasa 80 posts 201 karma points
    Mar 11, 2014 @ 11:11
    Manasa
    0

    Thanks a lot Jamie :)

  • Jamie Pollock 174 posts 853 karma points c-trib
    Mar 11, 2014 @ 11:13
    Jamie Pollock
    0

    No problem, my pleasure! If this answered your question please mark it as the answer. :)

Please Sign in or register to post replies

Write your reply to:

Draft