I have a Spring Boot microservice with an endpoint that returns a list of objects. I then use a HTML page with a dataTable and Thymeleaf to render this data to the user. What I'd like to do is to include a toggle button on the page that will filter the list of objects returned by the endpoint based on an attribute they share that only ever has one of two possible values.
Basically, I'd like to be able to filter the data in the model so that if a user clicks on the toggle button then only the objects with attributeIWantToFilterOn=RIGHT
are shown in the table. I'd like to avoid doing this by making another call to the endpoint and filtering the data in the back-end. Is this possible?
{
"objectId": 1,
"objectName": "its name 1",
"attributeIWantToFilterOn": "LEFT"
},
{
"objectId": 2,
"objectName": "its name 2",
"attributeIWantToFilterOn": "RIGHT"
}
]
You cannot alter HTML with Thymeleaf after it is rendered and sent to client-side.
You can use JavaScript for this, you mentioned dataTable, I am sure there is already a filtering function that supports pagination and such matters.