通用:
具体函数实现:
辅助功能:
- var dialogs = [
- saveAsDialogId, openDialogId,
- dataSetPickerDialogId, dataSourceEditorDialogId,
- ];
- var showElement = function (id) {
- if (!id) return;
- ($('#' + id)).css('display', 'block');
- };
- var hideElement = function (id) {
- if (!id) return;
- ($('#' + id)).css('display', 'none');
- };
- var hideDialogs = function () {
- dialogs.forEach(hideElement);
- }
- var showDesigner = function () {
- var info = GrapeCity.ActiveReports.WebDesigner.api.getReportInfo();
- var isDirty = GrapeCity.ActiveReports.WebDesigner.api.isReportDirty();
- document.title = info.name + (isDirty ? ' *' : '');
- showElement(designerId);
- GrapeCity.ActiveReports.WebDesigner.focus();
- };
- var makeOptions = function (baseOptions, additionalOptions) {
- return $.extend({}, baseOptions || {}, additionalOptions || {});
- }
-
复制代码
报表保存
- /* Optional: Save Report */
- var onSaveImpl = function (options) {
- baseServerApi
- .saveExistingReport({ id: options.reportInfo.id, content: options.reportInfo.content })
- .then(function (saveResult) {
- options.onSuccess({
- id: saveResult.Id,
- name: options.reportInfo.name
- });
- });
- };
-
复制代码
另存为:
- /* Optional: Save Report */
- var onSaveImpl = function (options) {
- baseServerApi
- .saveExistingReport({ id: options.reportInfo.id, content: options.reportInfo.content })
- .then(function (saveResult) {
- options.onSuccess({
- id: saveResult.Id,
- name: options.reportInfo.name
- });
- });
- };
-
复制代码
打开文件:
- /* Optional: Open Report */
- var onOpenImpl = function (options) {
- showElement(openDialogId);
- var loadedReportList = null;
- fileDialog.createOpenReportDialog(openDialogId, {
- locale: options.locale,
- api: {
- getReportsList: function () {
- return baseServerApi.getReportsList().then(function (reportsList) {
- loadedReportList = reportsList;
- return reportsList.map(function (reportInfo) {
- return { path: reportInfo.Name };
- });
- });
- },
- openReport: function (openOptions) {
- return new $.Deferred(function (def) {
- var reportInfo = (loadedReportList || []).find(function (r) {
- return r.Name === openOptions.path;
- });
- if (!reportInfo) return def.reject();
- GrapeCity.ActiveReports.WebDesigner.api.openReport({
- reportInfo: {
- id: reportInfo._id,
- name: reportInfo.Name,
- permissions: ['all'],
- },
- onFinish: function () {
- def.resolve({ id: reportInfo._id });
- },
- });
- });
- },
- },
- onSuccess: function (openResult) {
- hideElement(openDialogId);
- },
- onClose: function () {
- hideElement(openDialogId);
- showDesigner();
- },
- });
- };
-
复制代码
打开文件对话框:
- /* Optional: Open Report */
- var onOpenImpl = function (options) {
- showElement(openDialogId);
- var loadedReportList = null;
- fileDialog.createOpenReportDialog(openDialogId, {
- locale: options.locale,
- api: {
- getReportsList: function () {
- return baseServerApi.getReportsList().then(function (reportsList) {
- loadedReportList = reportsList;
- return reportsList.map(function (reportInfo) {
- return { path: reportInfo.Name };
- });
- });
- },
- openReport: function (openOptions) {
- return new $.Deferred(function (def) {
- var reportInfo = (loadedReportList || []).find(function (r) {
- return r.Name === openOptions.path;
- });
- if (!reportInfo) return def.reject();
- GrapeCity.ActiveReports.WebDesigner.api.openReport({
- reportInfo: {
- id: reportInfo._id,
- name: reportInfo.Name,
- permissions: ['all'],
- },
- onFinish: function () {
- def.resolve({ id: reportInfo._id });
- },
- });
- });
- },
- },
- onSuccess: function (openResult) {
- hideElement(openDialogId);
- },
- onClose: function () {
- hideElement(openDialogId);
- showDesigner();
- },
- });
- };
-
复制代码 报表预览界面
- /* Optional: Preview Report */
- var openViewerImpl = function (options) {
- hideElement(designerId);
- showElement(viewerContainerId);
- var viewerContainerOptions = makeOptions(options, {
- makeViewerUrl: function () {
- var baseUrl = 'http://localhost:58723/preview/';
- var reportId = encodeURIComponent(options.reportInfo.id);
- var language = options.locale;
- return baseUrl + reportId + '?lng=' + language;
- },
- });
- viewerContainer.renderViewerContainer(viewerContainerId, viewerContainerOptions, function () {
- var isTemporaryReport = options.reportInfo.isTemporary;
- if (isTemporaryReport) {
- var reportId = options.reportInfo.id;
- baseServerApi.deleteTemporaryReport({ id: reportId });
- }
- hideElement(viewerContainerId);
- showDesigner();
- });
- };
-
复制代码
设置数据集节点是否可见:
- /* Optional: Add Data Sets using Data Set Picker */
- var openDataSetPickerImpl = function (options) {
- var openInPanel = options.mode === 'Panel';
- if (!openInPanel) {
- hideDialogs();
- showElement(dataSetPickerDialogId);
- }
- dataSetPicker.renderDataSetPicker(openInPanel ? options.elementId : dataSetPickerDialogId, makeOptions(options, {
- serverApi: {
- getDataSetsList: baseServerApi.getDataSetsList,
- getDataSourcesAndDataSets: baseServerApi.getDataSourcesAndDataSets,
- },
- onClose: function () {
- options.onClose();
- if (!openInPanel) hideElement(dataSetPickerDialogId);
- dataSetPicker.dispose();
- }
- }));
- };
- var closeDataSetPickerImpl = function () {
- dataSetPicker.dispose();
- };
-
复制代码
设置数据源编辑器隐藏或可见:
- /* Optional: Add Data Sets using Data Set Picker */
- var openDataSetPickerImpl = function (options) {
- var openInPanel = options.mode === 'Panel';
- if (!openInPanel) {
- hideDialogs();
- showElement(dataSetPickerDialogId);
- }
- dataSetPicker.renderDataSetPicker(openInPanel ? options.elementId : dataSetPickerDialogId, makeOptions(options, {
- serverApi: {
- getDataSetsList: baseServerApi.getDataSetsList,
- getDataSourcesAndDataSets: baseServerApi.getDataSourcesAndDataSets,
- },
- onClose: function () {
- options.onClose();
- if (!openInPanel) hideElement(dataSetPickerDialogId);
- dataSetPicker.dispose();
- }
- }));
- };
- var closeDataSetPickerImpl = function () {
- dataSetPicker.dispose();
- };
-
复制代码
|
|