Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Change these things here (entity = "ModuleName.EntityName")
- var entity = "MyFirstModule.Audit";
- var typeAttr = "DownloadType";
- var pageAttr = "Page";
- // Don't change things below
- function getContentForm() {
- if (mx.router && mx.router.getContentForm) {
- return mx.router.getContentForm();
- }
- if (mx.ui && mx.ui.getContentForm) {
- return mx.ui.getContentForm();
- }
- if (mx.ui && mx.ui.getCurrentForm) {
- return mx.ui.getCurrentForm();
- }
- return {
- path: 'unknown'
- };
- }
- var widget = this;
- $(function () {
- var buttonCSV = $('.export-csv, .export-excel');
- if (buttonCSV) {
- buttonCSV.each(function () {
- var $this = $(this);
- var type = $this.hasClass('export-csv') ? 'CSV' : 'EXCEL';
- var buttonWidget;
- try {
- buttonWidget = dijit.registry.byNode($this.get(0));
- } catch (e) {
- console.error('Cannot find widget with class: ' + identifier);
- }
- if (buttonWidget) {
- buttonWidget.connect(buttonWidget, 'onClick', function () {
- if (!widget._contextObj) {
- console.warn('no obj');
- return;
- }
- mx.data.create({
- entity: entity,
- callback: function (obj) {
- obj.set(typeAttr, type);
- obj.set(pageAttr, getContentForm().path);
- mx.data.commit({
- mxobj: obj,
- callback: function () {
- mx.data.save({
- mxobj: obj,
- callback: function () {},
- error: function (err) {
- console.error(err);
- }
- })
- },
- error: function (err) {
- console.error(err);
- }
- });
- },
- error: function (err) {
- console.error(err);
- }
- })
- });
- } else {
- console.log('Cannot find widget for', $this);
- }
- })
- }
- });
Add Comment
Please, Sign In to add comment