set Selected Image in an ImageField - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

set Selected Image in an ImageField

  • set Selected Image in an ImageField
  • I have a user control designer that uses the ImageField component. I can pull out and save the GUID for the selected image in the js applyChanges() function with this code. 
    "this.get_imageSelector().get_selectedImageItem().Id;"

    The question,  when a user edits the component again how can I set the selected image in the refreshUI function? So the user will see what they selected last time. Everything I've found online and tried, such as "img.set_selectedImageId(imgid);", seem to point to functions on the ImageField that no longer exists.  I'm using the Sitefinity 6.3.


  • Hi Mike,

    You are correct. The  set_selectedImageId method does not get the job done. Since you persist the Id of the image, I would recommend doing a client-side web service call to the image service and populate the imageSelector as well as the image element displayed on the designer.

    The best thing here is that this can be achieved in just a few seconds using Sitefinity Thunder. I have recorded a video to walk you through the process by adding ImageSelector to my designer with "no hands", sort of say. Here is the video (http://screencast.com/t/MMIreAW0QTe).

    We are also now currently rebuilding the MediaSelectors to make them more straight forward for developers. I hope this helps!

  • This is exactly what I was looking for, thank you!  I was trying to use the ImageField in the designer. Only one problem, the Widget designer has a blank list of controls to pick from. Although I've created a number of test widgets with Thunder. How does this list find controls? 

    Any chance you can share the code too, in case I can't get the designer working? 
  • I built it a few days ago and I'm already using it on a number of pages. But none of our controls show up in that list? Any other ideas?
  • Hi Mike,

    Can you please make sure that you build your project after you have created the widget so that Sitefinity Thunder can discover it and display it under the list of available controls of the Widget designer.

    Regards,
    Sabrie Nedzhip
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
  • Hi Mike,

    It looks like a broken configuration. Any wrong configuration prevents the design from rendering. Things to watch out for are the LayoutTemplatePath and the IScriptControl members of the designer - SnippetGetScriptDescriptors() and SnippetGetScriptReferences() methods as well as the getters and setters which are in the JavaScript file of the designer.

    Instead of sending my code, could you please send me your code, so I can take a look and see what's going on?

    Thanks
  • I think you missed understood me. The widget works fine, and I can see the designer. It's the Sitefinity Thunder wizard (Designer for widget option) that doesn't list any of my widgets. My co-worker can see them, so it does seem like configuration.  How does it build this list? A web service to a running server. Or does it look at the source code of the project? I ask so I can find the project configuration problem for thunder. 

    thanks
    --mike
  • By default, Thunder looks for all UserControl, SimpleView or CompositeControl descendants with no registered designers and the search is scoped within the same project.

    So, if you have a solution with two projects A and B and somewhere within project B you click add a Designer for existing widget option, Thunder will look only into project B and list the classes eligible to be widgets and still not having designers associated with them using the ControlDesigner class decorator.

    Cheers,

    Peter 

  • Sorry I didn't update you, your last post was the trick. Once I understood the list was generated by widgets without a designer, I was able to strip out hooks to the default designers that the other Thunder wizard had generated and was able to run the Designer for existing widget wizard without a problem.  thank you!

  • Hello Mike,

    Can you please create a widget in the SitefinityWebApp project using Thunder, then build the project and try to add a designer to this widget. Please check out the video I have recorded for your convenience.

    If the issue still persists, you can open a support ticket and provide us with your project and the backup of your database in order to research the cause of the issue.

    Regards,
    Sabrie Nedzhip
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items