Copied to clipboard

Flag this post as spam?

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


  • Sebastiaan Janssen 5061 posts 15523 karma points MVP admin hq
    Sep 04, 2009 @ 13:52
    Sebastiaan Janssen
    0

    Custom DataType with multiple values

    I'm trying to create a custom DataType that will have to store multiple values. I need the controls from this datatype to always be grouped together, as I will be accessing the different textboxes from the codebehind.

    Do I really have to use a comma seperated string to save the values in the different fields or do I still have some other options?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 04, 2009 @ 14:08
    Dirk De Grave
    0

    Sebastiaan,

    You're not restricted in any way on how to save the values for the different boxes, but I'd go with xml, as this makes it really easy to use with xslt and such. 

     

    Btw, do you have an example of 

    "need the controls from this datatype to always be grouped together, as I will be accessing the different textboxes from the codebehind"

    as I'm not sure what exactly you're trying to say?

     

    Cheers,

    Dirk

  • fed 199 posts 70 karma points
    Sep 04, 2009 @ 14:31
    fed
    0

    You should check out Tim's blogpost about this http://www.nibble.be/?p=51

  • Sebastiaan Janssen 5061 posts 15523 karma points MVP admin hq
    Sep 04, 2009 @ 15:38
    Sebastiaan Janssen
    0

    @ Dirk yeah well what I really meant to say is that I would like to store three different properties but they are related. What I'm doing is: 

    - Using the ultimate picker to get autosuggest to find a content item
    - Javascript detects the pipe "|" in the string and uses the ID after the pipe to load an image from the selected content item
    - Selecting a coordinate on the image and putting it in a different textbox

    What I need to save is the selected content item AND the coordinates. So that would be two different properties on the documentType normally. 

    @ fed Tim's post looks interesting, not sure how I'd go about using that though.. 

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Sep 05, 2009 @ 16:11
    Nik Wahlberg
    0

    Sebastian, can you store tha value in a delimited format and parse it on the output? Just like you're parsing out the ID from the ultimatepicker, you could do something similar with your save/read.

    Just a thought.

    Thanks,
    Nik

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Sep 07, 2009 @ 01:55
    Peter Gregory
    1

    Hi Sebastiaan

    Have you looked at the Dynamic Properties Datatype that i have submitted to the package list? Not sure if its what you are looking for.

    This allows you create properties and property groups in the content tree.  The Datatype uses this structure to create a property on your content node that gives you those nodes as fields.

    eg your properties tree might look like this

    property 1
    Property Group
    ----Prop 1
    ----Prop 2
    ----Prop 3
    Property Group 2
    ----Prop 1
    ----Prop 2

    This would render in your content node as a list of grouped text fields like this

    Property 1 [Texbox]

    Property Group
    Prop 1 [Text Box]
    Prop 2 [Text Box]
    Prop 3 [Text Box]

    Property Group 2
    Prop 1 [Text Box]
    Prop 2 [Text Box]

    You are also able to set mandatory properties and have validation on the control

    This then saves a XML stub into the Umbraco.Config file that you can parse with XPath or however you like.  It looks like this on a node. (this is just an example and doesnt represent what I show above.

    <data alias="dynamicProperties">
    <dynamicProperties nodeId="1067">
    <dynamicProperty nodeId="1078"><![CDATA[12]]></dynamicProperty>
    <dynamicPropertyFolder nodeId="1068">
    <dynamicProperty nodeId="1070"><![CDATA[12]]></dynamicProperty>
    <dynamicProperty nodeId="1071"><![CDATA[asdf]]></dynamicProperty>
    </dynamicPropertyFolder>
    <dynamicPropertyFolder nodeId="1069">
    <dynamicProperty nodeId="1072"><![CDATA[3]]></dynamicProperty>
    <dynamicProperty nodeId="1073"><![CDATA[4]]></dynamicProperty>
    <dynamicProperty nodeId="1074"><![CDATA[5]]></dynamicProperty>
    <dynamicProperty nodeId="1075"><![CDATA[6]]></dynamicProperty>
    </dynamicPropertyFolder>
    </dynamicProperties>
    </data>

    The ids on the XML nodes point at the node from the properties tree. This allows you to get the fieldnames back at display time or any other information that you want to store against the properties. 

    Hope that helps

     

     

Please Sign in or register to post replies

Write your reply to:

Draft