Widget Designer Read From Database/Controller
Hello,
I'm in the process of writing a custom widget, and was wondering if it was possible for the widget designer to read values from a database/controller?
Thanks,
Zack
Hi Zack,
Basically, you add a property to the widget. Then from the designer, you have the ability to get and set it. The new property value is persisted in the database through the designer. If you change the property from the widget itself, it will not save - you can only 'consume' it from the widget.
You can find the following resources useful:
http://www.sitefinity.com/developer-network/videos/how-to-create-a-sitefinity-widget
http://docs.sitefinity.com/for-developers-create-a-custom-widget-with-a-simple-widget-designer
http://docs.sitefinity.com/overview-user-and-custom-widgets
Regards,
Nikola Zagorchev
Telerik
Hi Nikola,
Thanks for your reply, I don't think I explained myself well enough. I'm creating a Feather widget, and would like the widget designer to consist of values (in drop down lists) pulled in from a database, either through (hopefully) a controller in the MVC project or an outside service if necessary.
Thanks,
Zack
Hello
You can review how to override default widgets designer here:
https://github.com/Sitefinity/feather/wiki/Extend-widget-designer-with-additional-client-logic
or create a custom view:
https://github.com/Sitefinity/feather/wiki/Create-a-custom-designer-view
Here is a list of the content selectors:
Use Content Selectors
News selector
Page selector
Multisite page selector
Flat taxon selector
Hierarchical taxon selectorDynamic items selector
DateTime picker
TimeSpan selector
Language selector
Link selector
Site selector
Use a single content item selector
Use a multiple content item selector
Use a library selector
Use an image selector
Use a document selector
Use a role selector
Use content selectors in your frontend pages
List of selectors scripts
You can read the documentation about them and reuse them or create a custom one based on them. You can review the base selectors and scripts
sf-selectors.js sf-services.js
Hope this is useful.Hi Nikola,
I have updated the values when saving the form. Still I am
facing the same issue.
I am setting the property values as below.
propertyService.get()
.then(function (data)
if
(data)
$scope.properties = propertyService.toAssociativeArray(data.Items);
$scope.properties.CorticonEntityName.PropertyValue = newVal;
$scope.properties.CorticonFieldName.PropertyValue = newVal;
return
$http.get("corticon-demo.dyndns.org:8850/.../0");
,
Hi
This is the get function when you get the properties values from the service. You need to either bind to the $scope.properties.CorticonFieldName.PropertyValue directly or use a $watch.
The code you have pasted is not called on Save of the designer, but on open.
Regards,
Nikola Zagorchev
Telerik