To execute the example, create an HTML page and perform the following operations:
1. Add links to the following CSS files: PP.css, PP.Metabase.css.
Also add links to the following JS files: PP.js, PP.Metabase.js, PP.Express.js, and resources.ru.js.
2. Then in the <head> tag add a scenario that will create a dialog box for saving object to metabase:
<script type="text/javascript">
var metabase, eaxMdService, eaxAnalyzer, saveDialog;
// Function performed on HTML document loading
function onLoad() {
// Specify path to root folder with resources files
PP.resourceManager.setRootResourcesFolder("../resources/");
// Determine resource language settings
PP.setCurrentCulture(PP.Cultures.ru);
// Create a repository connection
metabase = new PP.Mb.Metabase({
PPServiceUrl: "/PPService.axd?action=proxy",
Id: "prognozplatform7",
UserCreds: {
UserName: "user",
Password: "password"
}
});
// Open repository connection
metabase.open();
// Create a service for working with express reports
eaxMdService = new PP.Exp.EaxMdService({
Metabase: metabase
});
// Open express report with the 108 key
eaxAnalyzer = eaxMdService.editDocument(108);
// Determine array of filters for dialog
var filters = [{
Filters: [2561, 0],
ResourceKey: "openDialogExpressReports",
iconIndex: 16
}, {
Filters: [2562, 0],
ResourceKey: "openDialogReports",
Content: 111,
iconIndex: 17
}];
// Determine array of languages for translating of saved object's name
var displayLanguages = [];
displayLanguages.push(PP.Cultures.ru.LCID); // Russian
displayLanguages.push(PP.Cultures.en.LCID); // English
// Create an object saving dialog
saveDialog = new PP.Ui.MetabaseSaveDialog({
DefaultId: "saveDialog102", // Saved object identifier
/* Determine saved object name */
DefaultName: "Indicators dynamics by region",
Metabase: metabase,
FiltersSet: filters, // Array of filters for dialog
CurrentFilter: filters[1], // Current filter
ImagePath: "../build/img/",
ShowOnlyFolders: false, // Display folders and files in object navigator
OpenToKey: parseInt(eaxAnalyzer.getParentKey() || 0),
// Determine translations of saved object's name in Russian and English
Names: [{
locale: PP.Cultures.ru.LCID,
name: "Indicators dynamics by region"
}, {
locale: PP.Cultures.en.LCID,
name: "Indicators dynamics by region"
}],
ShowTranslateButton: true, // Make visible button for displaying object name translations
// Set dialog for translating saved object's name into different languages.
TranslateDialog: new PP.Mb.Ui.TranslateDialog({
DisplayLanguages: displayLanguages
}),
SaveAsObject: function (sender, args) { // Process the SaveAsObject event
console.log("Name of saved object in different languages:");
var names = args.Names;
for (var i in names) {
var n = names[i];
console.log("Language code: " + n.locale + ", name: " + n.name);
}
}
});
saveDialog.show(); // Display a dialog for saving an object
}
</script>
3. In the <body> tag specify name of the function that creates a dialog box for saving an object to metabase as value of the onLoad attribute:
<body onload="onLoad();"></body>
After executing the example the HTML page will contain the MetabaseSaveDialog component:
After clicking the OK button the SaveAsObject event occurs, and handler of this event shows the following text in the browser console:
Name of the saved object in different languages: SaveDialog.html:79
Language code: 1033, Name: Dynamics indicators by region SaveDialog.html:83
Language code: 1049, Name: Dynamics of indicators by region
See also: