ShowPivot table action does not support multitenancy

Show Pivot action of table showing data from all tenant.

Secondly can I limit columns in pivot action.

How to solve this.

regards

Umesh

Hi!

ShowPivotAction provides API for including and excluding properties.

You can use withIncludedProperties() to show specific properties or withExcludedProperties() to exclude.

I am using following code to show pivot table, but this is giving nullpointexception

 @Subscribe
    private void onInit(InitEvent event) {
        ShowPivotAction showPivotAction = new ShowPivotAction(complianceMonitoringsTable);
        pivotBtn.setAction(showPivotAction);
    }

Am I missing something?

regards

Umesh

ShowPivotAction does not support new data containers. You can use it only in old screens with data sources.

Since v7.0.8 it is possible to use new ShowPivotAction that support data containers.
Please note:
com.haulmont.charts.gui.components.action.ShowPivotAction - for data sources
com.haulmont.charts.gui.components.action.list.ShowPivotAction - for data containers

And they are both provide the same API.

Hot to use new ShowPivotAction

In the layout you can add it to the table by defining action:

<groupTable id="customersTable" dataContainer="customersDc">
    <actions>
        ...
        <action id="showPivot" type="pivot_showPivot"/>
    </actions>
    <buttonsPanel id="buttonsPanel"
                  alwaysVisible="true">
        ...
        <button id="showPivotBtn" action="customersTable.showPivot"/>
    </buttonsPanel>
</groupTable>

In this case ShowPivotAction will show all available properties in pivot table according to his action rules.

If you want to configure your ShowPivotAction you can subscribe to given event and use PivotScreenBuilder:

@Inject
private GroupTable<Customer> customersTable;

@Subscribe("customersTable.showPivot")
private void onCustomersTableShowPivot(Action.ActionPerformedEvent event) {
    PivotScreenBuilder builder = getBeanLocator().getPrototype(PivotScreenBuilder.NAME, customersTable);
    builder.withItems(customersTable.getSelected())
            .withIncludedProperties(Collections.singletonList("age"))
            .build()
            .show();
}

The full example: showpivotdemo.zip (82.5 KB)

Thanks @Pinyazhin,

It works but with limitation-
As per document the showpivotaction shows pivot for selected data or if nothing selected then for all data.

Code suggested by you will show pivot for selected items only and
builder.withItems(customersTable.getItems().getItems())
show for all items.

should I have to code for original behavior?

regards

Umesh

It depends on your requirements and business logic.