+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Custom Widget Control Designer for MVC

Custom Widget Control Designer for MVC

8 posts, 0 answered
  1. James
    James avatar
    19 posts
    Registered:
    21 Jan 2011
    18 Jul 2012
    Link to this post
    Hey folks,

    Anyone see any documentation or examples on how to create a custom designer utilizing the new MVC functionality in 5.1?  We utilize custom designers for our widgets -- so if we were to begin any sort of strategy utilizing MVC we would need this functionality before moving forward.
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    18 Jul 2012
    Link to this post
    James,

    Designers will work with MVC widgets the way they do with the previous web form widgets, via an Attribute that links it to a designer. You can build these with webforms (I believe MVC desigers might be supported too but I'll double check on the status), linking to the public properties of the controller just as you would with a standard web forms widget.

    That being said, Thunder is definitely the way to go, and I know for sure that the team is cranking the next release ASAP that will generate MVC widgets and their designers, so stay tuned!

    The documentation for all of this is coming as well, there are already a few videos in the Getting Started Guide.

    hope this is helpful!
  3. Hywel
    Hywel avatar
    8 posts
    Registered:
    06 Aug 2013
    30 Aug 2013
    Link to this post
    I to am having issues with getting "Full" MVC. I can get the widgets created fairly easily, I use a third party Power tool to link an  MVC designer to the Widget, which seems to work, but I have no clue how to actually save any data.
    In webforms there are loads of examples shoeing the JS to write, how to wire it up etc, there is nothing like this for MVC. I'm starting to think that the only way to go s MVC front end and webform designers.......... not ideal!!!
    If anyone has any better way than this please let me know.
  4. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    02 Sep 2013
    Link to this post
    Hi all,

    A while ago we shared code on GitHub which lets you write designers using MVC. You can find an explanation here: https://github.com/Sitefinity/PowerTools/wiki/Mvc-Widget-Designers

    The source code is also available in that repository. What this does is that it replaces the default Property Editor (the thing that opens when you click Edit on a widget). The property editor is the host, and its job is to open a custom designer if there is one, or show the default Advanced view. Since the default one assumes WebForms, this code above replaces it with a slightly customized one.

    I suppose this is what Hywel is using. The above lets you write MVC controllers which serve as designers of other controllers. In order to get and set properties, however, you will have to use JavaScript (like you do in WebForms). All the designer does is call a service and set the values of the properties serialized as JSON. You don't need to do that manually. Just override the refreshUI() and applyChanges() methods in your script and set the properties of the JavaScript object there. This process is exactly the same as in WebForms. 

    There is no server-side (C#) way to get/set properties. It all goes through a service, and the service persists the properties in the DB.

    Regards,
    Slavo
    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 Public Issue Tracking system and vote to affect the priority of the items
  5. Hywel
    Hywel avatar
    8 posts
    Registered:
    06 Aug 2013
    04 Sep 2013 in reply to Slavo
    Link to this post
    Thanks for the help, I'm so glad its possible!

    Sorry to ask for more help, but Is there any chance you could add a JS example, along with how you wire the JS to the MVC part -the get script reference / descriptor equivalent in user controls?  Basically i'm looking for a way to do RegisterClientScript Equivelent
    Sorry if this is really simple, but until I get the basics in place I am stuck.
  6. Hywel
    Hywel avatar
    8 posts
    Registered:
    06 Aug 2013
    04 Sep 2013
    Link to this post
    you said "Just override the refreshUI() and applyChanges() methods" what exactly am I overriding, and how do I register my script?
    I'm a bi lost as to how SF/MVC knows which script to use for my view....
  7. Hywel
    Hywel avatar
    11 posts
    Registered:
    04 Sep 2013
    09 Sep 2013
    Link to this post
    Still having trouble with this, does anyone know if it will be made simpler in future release?
  8. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    06 Dec 2016
    12 Sep 2013
    Link to this post
    Hi,

    The designer component form MVC works like the designer for web forms widget (they are the same in both cases MVC and web forms), for throughout explanation of how the designers retrieves data and saves it using applyChanges and refreshUI functions in the designer java-script refer to the video walktrough in this blog post.

    Regards,
    Stanislav Velikov
    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 Public Issue Tracking system and vote to affect the priority of the items
8 posts, 0 answered