Copied to clipboard

Flag this post as spam?

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


  • Tom Smith 98 posts 172 karma points
    Jul 25, 2011 @ 16:08
    Tom Smith
    0

    Using uComponents datatypes with contour

    Hi All,

    On my contour form I need a way of allowing the user to select an image from a collection of images. (i.e. "Choose an image from our collection")

    This will probably need some form of custom field type, 

    So I was wondering if I could use one of the uComponents datatypes (either Dropdown list with images or more preferably, datatype grid [grid of labels containing images]) so I didn't have to write my own custom WebControl

    I can't seem to work out how to get access to a uComponents datatype in backend code, let alone put a field type wrapper around one,

    Not sure where to start! 

    Many Thanks, Tom

  • Tom Smith 98 posts 172 karma points
    Jul 25, 2011 @ 19:13
    Tom Smith
    1

    Ah ha! 

    After a bit more playing I managed to come up with somthing;

    1. create a datatype based on the uComponents Image Drop Down List. Give it a list of image prevalues as appropriate,

    2. In contour, create a new prevalue souce - select the 'from datatype' option and use the datatype just created

    3. Download the contour shared source and copy and paste the DropDownList field type into a new class

    4. The uComponents datatype spits out prevalue data in the form Alias|ImagePath so if you amend the DropDownList class to split by pipe ("|" character) then you can do stuff with the alias and the pathname e.g.

    foreach (var prevalue in this.AssociatedField.PreValueSource.Type.GetPreValues(this.AssociatedField))

    {

    string[] data = DictionaryHelper.GetText(prevalue.Value).Split('|');

    ListItem li = new ListItem(data[0], data[1]);

    dd.Items.Add(li);

    }

    So my modified dropdown list spits out <option>'s with the text set as the prevalue alias, and the value set as the prevalue value (in this case the image path)

    5. Set the desired contour field to use the new type, and the prevalue source created earlier 

    I then used some simple jQuery to display a preview of the selected item client side. This will do nicely for my current needs but would still be interested in seeing if you can wrap uComponents core datatypes directly,

    Many Thanks,

    Tom

  • Josh Reid 182 posts 257 karma points
    Apr 13, 2012 @ 22:55
    Josh Reid
    0

    I agree- Would like to use the wonderful xpath checkbox list!
    Anyone managed to accomplish or know if this is possible?

    Thanks
    Josh

Please Sign in or register to post replies

Write your reply to:

Draft