Data Resolvers
Could someone explain how and when Data Resolvers are used (Settings -> Advanced -> Data -> Data Resolvers)? My assumptions is that you they are applied to content prior to presentation so you can do some pre-processing of data. The documentation is a little thin so any help is appreciated.
Hello Shawn,
DataResolver resolves data properties for data binding - in most of the case the DataResolver is used when we bind a control to a list of content items and we need to resolve the url of the single content item and set it to a NavigateUrl property of a HyperLink control. When you click on the link you will go to details mode and you will see the single content item.
sample
link.NavigateUrl = DataResolver.Resolve(ContentItemDataItem,
"URL"
, host.UrlKeyPrefix,
null
);
LabelControl.Text = DataResolver.Resolve(dataItem,
"Author"
, someformat);
I would like to do some pre-processing of Content before it's displayed...specifically to html content entered in the RadEditor. Exactly like what Sitefinity does to resolve hyperlinks and images with Telerik.Sitefinity.Web.UI.Utilities.LinkParser class. I would like to take specific datatags and transform them. For example, I would like to look for occurrences of Year and display DateTime.Now.Year in its place. Basically, I would like to wire in classes similar to the LinkParser class that performs some logic on html..replaces values, etc.. Is there a way to accomplish this via configuration?
Hello Shawn,
The only way to do this is by creating a custom class that inherits from the control you want to modify and override some of its method where the content data is bound. You also have to modify the control template which represents the data.
If you want to do this for RadEditor control you should create a wrapper of the control similar to ContentBlok control.
All the best,
Ivan Dimitrov
the Telerik team