Customizing Report Manager

Report Manager is a complex widget created with Webix Jet, the MV* framework for Webix Library. It is a ready-to-use application with minimum configuration settings but has API for redefining the logic of inner modules.

You will need to study the source code to customize views and models.

Jet App and Inner Modules

Report Manager is built as a Jet App and wrapped into a Webix view, so you can initialize it in either of the ways.

Views

The interface of Report Manager is split into parts (views). Each view is a class that extends the JetView class and has own handlers for setting the configuration and logic.

The sources for interface parts (Jet Views) are located in the sources/views folder.

views
  menu.js
  editor
    column.js
  ...

Go to the Class Map page to see the list of all Jet views in Report Manager and where they are in the interface.

Models/Services

Report Manager models contain the logic for working with scales and data. They are defined as Jet Services.

The sources for models (Jet Services) are located in the sources/models folder.

models
  Backend.js
  Charts.js
  Local.js
  Helpers.js

Service methods are called by the UI and can be called by a programmer as:

$$("reports").getService("helpers").findOptions(collection, regexp);

Customizing Views

  • you can override the config() method for changes in the UI
  • you can override the init() for changes in the UI and behavior
  • you can override any existing method but with a caution
  • you can add and call your own methods

Firstly, create you own view class by inheriting it from one of the default views or from reports.views.JetView:

class CustomToolbar extends reports.views.toolbar {
    config() {
        // get JSON object with configuration
        const ui = super.config();
        // exact changes depend on a particular view
        ui.height = 60;
        return ui;
    }
    init() {
        // call default logic
        super.init();
        // custom logic below
        this.doSomething();
    }
    doSomething() {
        // do something on init
    }
}

Secondly, replace the default view via the override map:

webix.ui({
    view: "reports",
    url: "https://docs.webix.com/reports-backend/",
    override: new Map([[reports.views.toolbar, CustomToolbar]]),
});

Adding richselect to the toolbar

To add richselect to the toolbar create a custom class (CustomToolbar) and inherit it from the default reports.views["toolbar"] one. Inside the config method add a new element to the JSON configuration as the following:

class CustomToolbar extends reports.views['toolbar'] {
    config() {
        let ui = super.config();
        let elements = ui.elements;
 
        // adding richselect to the toolbar elements array
        elements.push({
            view: 'richselect',
            value: 'en',
            options: [
                { id: 'en', value: 'en' },
                { id: 'ru', value: 'ru' },
            ],
            width: 65,
            on: {
                onChange: (value) => {
                    webix.alert("'" + value + "' locale selected");
                },
            },
        });
        return ui;
    }
}

Related sample:  

You can find more use cases in the How-tos article.

Notes

1. We do not recommend to remove any component from the interface as the inner logic might still try accessing it. Instead, hide the components.

class CustomToolbar extends reports.views.toolbar {
    init(view) {
        // default logic
        super.init();
        // hide "New+" button
        view.queryView('button', 'all')[1].hide();
    }
}

2. You can access component instances within a Jet view by:

  • using the $$(id) method of JetView.

It works for an inner component that is assigned the localId setting.

init() {
    // default logic
    super.init();
    // get instance of the component with "list" localId
    const reports = this.$$("list");
}
init(view) {
    // default logic
    super.init();
    // get instance of the first button
    const button = view.queryView("button");
}

3. You can find out whether the app is currently compact from any view or service method as:

const compact = this.getParam('compact', true);

4. You can get state properties from any view or service method as:

const state = this.app.getState();
// or
const state = this.getParam('state');

Customizing Jet Services

  • you can add and call your own methods
  • you can override any existing method but with a caution

Firstly, create your own service class and inherit it from one of the default services:

class MyBackend extends reports.services.backend {
    getModules() {
        // client-side data
        return webix.promise.resolve(modules);
    }
}

Secondly, replace the default service via the override map:

webix.ui({
    view: 'reports',
    url: 'https://docs.webix.com/reports-backend/',
    override: new Map([[reports.services.backend, MyBackend]]),
});

Related sample:  Report Manager: Local Data

You can find more information about Report Manager Backend service in the Working with Server article.

Backward Compatibility

Report Manager is extremely flexible when it comes to customizations: you can change almost anything in it. However, keep in mind the following:

  • The inner logic of Report Manager modules may change in future releases.
  • We will try to maintain method signatures, but breaking changes might happen if they are necessary for further development of the widget.

Code for IE11 and Edge must be with different syntax.

Back to top