Copied to clipboard

Flag this post as spam?

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


  • Timsn 121 posts 231 karma points
    Jul 11, 2009 @ 18:23
    Timsn
    0

    Get custom dropdown datatype values

    I've created a datatype with a dropdown list as rendercontrol and added some prevalues to choose from.

    But how do I get these prevalues in my usercontrol codebehind? I want to create a form where I can choose one of the prevalues from the dropdown list set in the datatype.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 11, 2009 @ 21:03
    Dirk De Grave
    102

    Hi,

     

    Can use:

    PreValues.GetPreValues(datatypeId)

    to retrieve a sorted list of prevalues for a specific dropdown. You'll have to reference the cms assembly. parameter datatypeId is of type int; to find out your id, hover over the datatype in the Developer section and have a look at bottom left

    javascript:openDataType(datatypeId)

    Hope this helps.

    Regards,

    /Dirk

     

  • Timsn 121 posts 231 karma points
    Jul 11, 2009 @ 21:43
    Timsn
    0

    Perfect! To be precise, it's in the

    umbraco.cms.businesslogic.datatype

    Namespace. Thank you.

  • Stipo 11 posts 31 karma points
    Aug 07, 2009 @ 22:03
    Stipo
    0

    I am sorry for my bad english, but must too learn it better. I come from Germany.

    thanks for this helps, but i search the method to request the DataTypeID by the name.

    greets Stipo

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Aug 07, 2009 @ 22:27
    Dirk De Grave
    0

    Hi stipo,

    As far as I'm aware, you can only get the datatype definition either by id or by its unique guid

    public DataTypeDefinition(int id)
    public DataTypeDefinition(Guid id)

    . I'd recommend against querying the db directly, but it's also possible that way. Lastly, you could also consider getting all datatypes using

    public static DataTypeDefinition[] GetAll()

    and as a datatype is just another 'cms node', you could iterate the list to find the one you need based on the 

    .Text

    property

     

    Hope this helps.

     

    Regards,

    /Dirk

  • Stipo 11 posts 31 karma points
    Aug 07, 2009 @ 23:07
    Stipo
    0

    Hi Dirk,

    thanks for helps. I hope understand correctly your help, and i currently test it.
    Else i must go the same way and querying the db directly.

    But this feature is too needed anywhere, and developers can do this in the Sources.

    I have come to this, after copying the WebSite over packages, that the DataTypeId ID never the same is.

    Greets Stipo

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Aug 07, 2009 @ 23:30
    Dirk De Grave
    0

    Hi Stipo,

     

    Have to add some extra info:

    A datatype is more to be considered as a 'prototype' as it might serve as the basis of one or more data types. (For example, one may use the ultimate picker more than once - let's say as being a checkbox list iterating all child nodes of node X, or as a dropdownlist listing all child nodes of node Y)

    In the above example, two datatypes would be created, both based on the same datatype 'prototype'. Both datatypes will have the same guid identifier, but have a different id (which is the id of the node). Getting prevalues is always based on the id of the datatype.

    I agree that the 'ID' may be different, but the Guid will remain across multiple umbraco installations.

     

    Cheers,

    /Dirk

  • Stipo 11 posts 31 karma points
    Aug 07, 2009 @ 23:56
    Stipo
    0

    Hi Dirk,

    thanks, you helping me very. I need the Guid in my methode.

    I have the last question. Where can see what for Guid have my DataType?

    Greets Stipo

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Aug 08, 2009 @ 00:30
    Dirk De Grave
    0

    It's something you'll have to lookup either in code (if your datatype implements IDataType, it will implement a property 'Id' which returns the Guid), otherwise perform a db lookup.

    For example, the 'label' datatype (which is available oob in umbraco) has a node id = -92 (table umbracoNode). Find that id in table cmsDatatype and find the corresponding objectId. Column objectid holds the guid of the datatype.

     

    Hope this helps.

     

    Regards,

    /Dirk

  • Stipo 11 posts 31 karma points
    Aug 08, 2009 @ 00:47
    Stipo
    0

    Thanks. I have enought information to developing my UserControl.

    All others can self find, else then i question in a new topic with my problem.

    Greets Stipo

Please Sign in or register to post replies

Write your reply to:

Draft