Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter in DataGrid column headers #1752

Closed
knstvk opened this issue May 29, 2023 · 6 comments · Fixed by #2105
Closed

Filter in DataGrid column headers #1752

knstvk opened this issue May 29, 2023 · 6 comments · Fixed by #2105
Assignees
Milestone

Comments

@knstvk
Copy link
Contributor

knstvk commented May 29, 2023

Like in this example: https://vaadin.com/docs/latest/components/grid/#filtering

@knstvk knstvk added candidate Possible candidate for future releases in: flowui labels May 29, 2023
@glebfox glebfox added the size: M label Jul 5, 2023
@knstvk knstvk added this to October 2023 release 2.1 in Jmix Roadmap Jul 12, 2023
@KremnevDmitry KremnevDmitry removed the candidate Possible candidate for future releases label Jul 26, 2023
@KremnevDmitry KremnevDmitry self-assigned this Jul 26, 2023
@KremnevDmitry
Copy link
Contributor

KremnevDmitry commented Sep 18, 2023

How to:

To enable filtering in headers, you need to add the attribute filterable = true to the <column/> tag.

E.g.

Only for email:

            <columns>
                <column property="username"/>
                <column property="firstName"/>
                <column property="lastName"/>
                <column property="email" filterable="true"/>
                <column property="timeZoneId"/>
                <column property="active"/>
            </columns>

@knstvk
Copy link
Contributor Author

knstvk commented Oct 11, 2023

Filter indicator must always be visible regardless of the column width, the same as sorting indicator.

<columns filterable="true">
    <column property="username"/>
    <column property="firstName"/>
    <column property="lastName"/>
    <column property="email"/>
    <column property="timeZoneId" filterable="false"/>
    <column property="active"/>
    <column property="onboardingStatus"/>
    <column property="department"/>
    <column property="joiningDate"/>
</columns>
image

@knstvk
Copy link
Contributor Author

knstvk commented Oct 11, 2023

Define filterable="true" for a reference attribute. The filter will show entityPicker. Try to select an entity in the picker.

java.lang.IllegalStateException: A component 'EntityPicker' is not attached to a view
	at io.jmix.flowui.component.UiComponentUtils.getView(UiComponentUtils.java:268)
	at io.jmix.flowui.DialogWindows.lookup(DialogWindows.java:205)
	at io.jmix.flowui.action.entitypicker.EntityLookupAction.execute(EntityLookupAction.java:167)
	at io.jmix.flowui.action.valuepicker.PickerAction.actionPerform(PickerAction.java:75)
	at io.jmix.flowui.kit.component.valuepicker.ValuePickerButtonActionSupport.lambda$setAction$c6c19f47$1(ValuePickerButtonActionSupport.java:55)
	at com.vaadin.flow.component.ComponentEventBus.fireEventForListener(ComponentEventBus.java:233)
	at com.vaadin.flow.component.ComponentEventBus.handleDomEvent(ComponentEventBus.java:475)
	at com.vaadin.flow.component.ComponentEventBus.lambda$addDomTrigger$dd1b7957$1(ComponentEventBus.java:292)
	at com.vaadin.flow.internal.nodefeature.ElementListenerMap.lambda$fireEvent$2(ElementListenerMap.java:447)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at com.vaadin.flow.internal.nodefeature.ElementListenerMap.fireEvent(ElementListenerMap.java:447)
	at com.vaadin.flow.server.communication.rpc.EventRpcHandler.handleNode(EventRpcHandler.java:62)
	at ...

@KremnevDmitry
Copy link
Contributor

Filter indicator must always be visible regardless of the column width, the same as sorting indicator.

<columns filterable="true">
    <column property="username"/>
    <column property="firstName"/>
    <column property="lastName"/>
    <column property="email"/>
    <column property="timeZoneId" filterable="false"/>
    <column property="active"/>
    <column property="onboardingStatus"/>
    <column property="department"/>
    <column property="joiningDate"/>
</columns>
image

It's impossible to style a column header this way.
Vaadin doesn't have such an API, and styling is impossible, since the required elements are closed in Shadow DOM.
We only have the ability to style the content inside the header.

@KremnevDmitry
Copy link
Contributor

Define filterable="true" for a reference attribute. The filter will show entityPicker. Try to select an entity in the picker.

java.lang.IllegalStateException: A component 'EntityPicker' is not attached to a view
	at io.jmix.flowui.component.UiComponentUtils.getView(UiComponentUtils.java:268)
	at io.jmix.flowui.DialogWindows.lookup(DialogWindows.java:205)
	at io.jmix.flowui.action.entitypicker.EntityLookupAction.execute(EntityLookupAction.java:167)
	at io.jmix.flowui.action.valuepicker.PickerAction.actionPerform(PickerAction.java:75)
	at io.jmix.flowui.kit.component.valuepicker.ValuePickerButtonActionSupport.lambda$setAction$c6c19f47$1(ValuePickerButtonActionSupport.java:55)
	at com.vaadin.flow.component.ComponentEventBus.fireEventForListener(ComponentEventBus.java:233)
	at com.vaadin.flow.component.ComponentEventBus.handleDomEvent(ComponentEventBus.java:475)
	at com.vaadin.flow.component.ComponentEventBus.lambda$addDomTrigger$dd1b7957$1(ComponentEventBus.java:292)
	at com.vaadin.flow.internal.nodefeature.ElementListenerMap.lambda$fireEvent$2(ElementListenerMap.java:447)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at com.vaadin.flow.internal.nodefeature.ElementListenerMap.fireEvent(ElementListenerMap.java:447)
	at com.vaadin.flow.server.communication.rpc.EventRpcHandler.handleNode(EventRpcHandler.java:62)
	at ...

Extracted to the separate issue: #2369

@KremnevDmitry
Copy link
Contributor

KremnevDmitry commented Oct 17, 2023

After a meeting with the GG and KK, it was decided to assign experimental status to this feature.
In order for the filter icon to be displayed correctly in the DataGrid header, additional adjustment of the header (column) sizes is required. You need to set the width and resizable = false so that the filter button is not hidden.

Any improvements will be implemented later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants