Custom Widget Control Designer for MVC

Posted by Community Admin on 03-Aug-2018 02:13

Custom Widget Control Designer for MVC

All Replies

Posted by Community Admin on 18-Jul-2012 00:00

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.

Posted by Community Admin on 18-Jul-2012 00:00

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!

Posted by Community Admin on 30-Aug-2013 00:00

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.

Posted by Community Admin on 02-Sep-2013 00:00

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

Posted by Community Admin on 04-Sep-2013 00:00

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.

Posted by Community Admin on 04-Sep-2013 00:00

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....

Posted by Community Admin on 09-Sep-2013 00:00

Still having trouble with this, does anyone know if it will be made simpler in future release?

Posted by Community Admin on 12-Sep-2013 00:00

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

This thread is closed