Formating paging counter in table

Hello,

is it possible to format the numbers in the paging counter of a table so that they are displayed in the same way as, for example, the total number?

2022-09-20 14_17_14-aKSM Anwendung – Mozilla Firefox

Greetings
Andreas

Hello!

Unfortunately, RowsCount component does not provide the ability to change formatting of “from” and “to” values.

For now, the only way is to extend WebRowsCount component and override onCollectionChanged(). You can check the example: How is the way to extends Components like Button. But in your case, I think you should use the same name like RowsCount.NAME.

Hallo @Pinyazhin ,

thank you for the solution:

package de.agentes.ksm.web.components;

import com.haulmont.cuba.core.global.DatatypeFormatter;

import javax.inject.Inject;

public class WebRowsCount extends com.haulmont.cuba.web.gui.components.WebRowsCount {

    @Inject
    private DatatypeFormatter datatypeFormatter;

    @Override
    protected String countValue(int start, int size) {
        if (size == 0) {
            return datatypeFormatter.formatInteger(size);
        } else {
            return datatypeFormatter.formatInteger(start + 1) + "-" + datatypeFormatter.formatInteger(start + size);
        }
    }
}

ui-component.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<components xmlns="http://schemas.haulmont.com/cuba/components.xsd">
    <component>
        <name>rowsCount</name>
        <class>de.agentes.ksm.web.components.WebRowsCount</class>
    </component>
</components>

Result:

2022-09-21 14_13_50-aKSM Anwendung – Mozilla Firefox

Greetings
Andreas

1 Like