jmix-framework / jmix

Jmix framework
https://www.jmix.io
Apache License 2.0
694 stars 123 forks source link

Support declarative definition of components renderers in XML #3101

Closed glebfox closed 3 weeks ago

glebfox commented 7 months ago

Components like DataGrid, ComboBox, VirtualList support renderers to change visual appearance of their columns/list. Currently, renderer can be defined only in Controller code.

It'd be convenient to be able to define renderer in XML. One of the options is to create a composite component and use it as a renderer in XML.

Related issues: https://github.com/jmix-framework/jmix/issues/2707 https://github.com/jmix-framework/jmix/issues/841

glebfox commented 2 months ago
KremnevDmitry commented 1 month ago

Idea to implement in the next iteration

Custom renderer markup in XML:

<virtualList itemsContainer="usersDc">
    <renderer>
        <vbox>
            <button id="rendererButton"/>
            <textField property="username"/>
        </vbox>
    </renderer>
</virtualList>

Declarative handlers for components inside:

    @Supply(to = "virtualList.@renderer.rendererButton", subject = "clickListener")
    public ComponentEventListener<ClickEvent<JmixButton>> onRendererButtonClick(User item) {
        return clickEvent -> {
            item.doSomething();
        };
    }
SergeiAksenov2 commented 3 weeks ago

Tested on: Jmix version: 2.4.999-SNAPSHOT Jmix Studio plugin version: 2.4.SNAPSHOT6859-242