-
Notifications
You must be signed in to change notification settings - Fork 0
/
Viewer.cshtml
58 lines (54 loc) · 2.32 KB
/
Viewer.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<script type = "text/html" id = "employeeID-custom-editor" >
<div data-bind="dxTreeList: { dataSource: data, columns: columns, showBorders: true,
selection:{mode: 'single'}, onSelectionChanged: onTreeListSelectionChanged,
onInitialized: onTreeListInitialized}">
</div>
</script>
<script type="text/javascript">
// Specifies the endpoint for the tree list data.
var data = window.location.protocol + "//" + window.location.host + "/Home/ListEmployees";
// Specifies the columns to display in the tree list.
var columns = [{ dataField: "name", caption: "Name" }, { dataField: "title", caption: "Title" }];
var p_employeeID_editor;
var parametersModel;
function customizeParameterEditors(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];
};
if (e.parameter.name == "p_employeeID") {
e.info.editor = { header: 'employeeID-custom-editor' };
};
};
function onTreeListInitialized(e) {
p_employeeID_editor = e.component;
}
function onTreeListSelectionChanged(e) {
if (e.selectedRowsData.length > 0) {
var selectedEmployeeID = e.selectedRowsData[0].id;
parametersModel.p_employeeID = selectedEmployeeID;
}
};
function onParametersReset(s, e) {
p_employeeID_editor.deselectAll();
};
function onBeforeRender(s, e) {
e.tabPanel.width = 500;
parametersModel = e.parametersModel;
};
</script>
@Html.DevExpress().WebDocumentViewer(settings =>
{
settings.Name = "WebDocumentViewer1";
settings.ClientSideEvents.BeforeRender = "onBeforeRender";
settings.ClientSideEvents.CustomizeParameterEditors = "customizeParameterEditors";
settings.ClientSideEvents.ParametersReset = "onParametersReset";
}).Bind("TestReport").GetHtml()