xtrareports-405704-web-reporting-blazor-reporting-web-document-viewer-customization-customize-parameter-editors.md
This topic shows how to customize the built-in parameter editors in the JavaScript-based Document Viewer.
View Example: Blazor Reporting - UI Customization API
Handle the CustomizeParameterEditors event and use the info.editor.extendedOptions property to customize the DateBox editor options.
window.ViewerCustomization = {
// Remove the time portion from the DateTime parameter editor
onCustomizeParameterEditors: function(s, e) {
if (e.parameter.type === "System.DateTime") {
e.info.editor = $.extend({}, e.info.editor);
e.info.editor.extendedOptions = $.extend(e.info.editor.extendedOptions || {}, { type: 'date' });
}
}
}
<head>
@...@
@DxResourceManager.RegisterScripts((config) => config.Register(new DxResource("/customization.js", 900)))
@...@
</head>
<DxDocumentViewer ReportName="SampleReport" Height="1000px" Width="100%">
<DxDocumentViewerCallbacks CustomizeParameterEditors="ViewerCustomization.onCustomizeParameterEditors" />
</DxDocumentViewer>
Handle the CustomizeParameterEditors event and add a validation rule to the editor’s validationRules array.
window.ViewerCustomization = {
// Remove the time portion from the DateTime parameter editor
onCustomizeParameterEditors: function(s, e) {
if (e.parameter.type === 'System.DateTime') {
e.info.editor = $.extend({}, e.info.editor);
e.info.editor.extendedOptions =
$.extend(e.info.editor.extendedOptions || {},
{ type: 'date' }, { displayFormat: 'dd-MMM-yyyy' });
var validationRule = {
type: "range",
min: new Date(2000, 0, 1),
message: "We do not retain data prior to the year 2000."
};
e.info.validationRules = [validationRule];
}
}
}
<head>
@...@
@DxResourceManager.RegisterScripts((config) => config.Register(new DxResource("/customization.js", 900)))
@...@
</head>
<DxDocumentViewer ReportName="SampleReport" Height="1000px" Width="100%">
<DxDocumentViewerCallbacks CustomizeParameterEditors="ViewerCustomization.onCustomizeParameterEditors" />
</DxDocumentViewer>
The customized parameter editor appears as follows: