Vaadin 8 Grid : hide/unhide selected row - java

I am using Vaadin8 Grid with Multi Selection. I want to implement an option to hide a row or unhide row in the Grid.
Has any one already implemented this feature? Appreciate if i get some pointers on how to implement it feature.
TIA

The correct way to implement selective display Grid rows is to use Filtering in DataProvider For example the ListDataProvider, which is used by Grid has API's for filtering. So items passing the filters are shown, and those which are not passing the filters are not shown.
There is another question about Filtering with Grid here at StackOverflow: How to add grid filters in Vaadin 8? Which has code example of filtering. Usually Lambda expressions are used as filters. You can create custom filters. For example in your case you could have list of ids in the filter, and filter out rows that match those ids.

Related

Can nattable group by functionality be used to sort?

So i am thinking about Nattable for a project, it looks excellent, but one of my requirement is to have a good configurable sort on multiple columns with a clear display of what is happening, having see the group example, this is a great bit of functionality:
Where you can drag columns in to a bar that then groups the data by those values, this is what I would like for sorting, ie I don't want the tree expansion, or new rows added, I just want the table sorted in the order that I have dragged the columns. I am trying to work out if this is going to be possible in nattable because the sorting examples for multiple columns are lacklustre compared to this grouping bar, so can it be done?
Sorting multiple columns in NatTable works if the ISortModel supports it.
The _509_SortHeaderLayerExample has a custom ISortModel that does not evaluate the accumulate parameter. The _602_GlazedListsSortingExample uses the GlazedListsSortModel that supports sorting by multiple columns.
Using the DefaultSortConfiguration sorting by multiple columns works if SHIFT + ALT are pressed while clicking on the column header. Using the SingleClickSortConfiguration only the ALT key is pressed while clicking on the column header.
With a good understanding of the NatTable mechanisms it is possible to implement a sorting similar to the grouping UI. You need the grouping header and implement that it should sort instead of group. It is not supported out of the box.

Vaadin - adding components as elements of another components

I've been using a ComboBox to store some values and make a selection from those values, but the problem is, ComboBox, as it is, only allows one selection at the time and I need multiple selections, ie checkboxes, but that cannot be done via Vaadin. I figured if I could present checkboxes as the elements of the ComboBox, that would solve the issue, except adding components to a component that is not a layout doesn't seem to be possible.
I've done this tutorial https://vaadin.com/docs/-/part/framework/components/components-customcomponent.html
Basically it combines two Vaadin components into one panel and displays them together, but that's not what I need, as I need certain components to be placed inside a parent component.
So what are my options if I'm to do this?
This is not an answer to the question that you are asking (component within a component), but rather the underlying problem that you present. In other words, I believe your question is an example of an XY problem.
I think you want to use a Grid with multi-select turned on. In this mode, check boxes are automatically added to each row and there is a checkbox in the header to allow toggling all on/off, ability to filter, ability to sort columns, etc. See the documentation for more details.

Grid component and sorting with custom sort listener

I'm using grid component and default column sort behavior doesnt work for me correctly. I'm using a paged data so current grid data content is just a part of the entire data set. And default sorting feature sorts only data on screen and I need send the sort options to my database query. For this I added custom sort listener as on the example ...
e.g. grid.addSortListener(e -> this.sortListener(e));
... so I can catch the sort order change user does on screen which works fine. But how can I disable the default sorting the Vaadin does in grid?
The Grid redirects the sort to Container.sort() so you could override this method in your Container and ignore it.
David Marko,
You will you that following code
grid.sort("Column Name", SortDirection.ASCENDING);
It was working well

NatTable - Quick Search in the Excel like filters

I have a NatTable grid and use excel like filters in order to filter my content. However, I want to add a feature to the filters as a quick search (not unlike the excel one)
Can anyone give me advice on how I might do that?
I've noticed that the other nattable filter FilterRowHeaderComposite has a textbox filter for filtering words that contain the typed string, so I wonder if I could somehow combine it with the ComboBoxFilterRowHeaderComposite to get a combobox with a quick-search feature.
Can I have two header layers, one with comboboxes and the other with the textbox?
Or maybe combine them in one cell as to work like the regular filter and only when I press on the filter icon to expand into the comboboxes context menu?
Or are there already implementations for this feature I'm trying to do, in NatTable 1.2.0 or 1.3.0? (I'm currently using 1.1.1)
NatTable questions typically get more attention in the Eclipse forum as you already noticed.
For others having the same question, I answered the question there: https://www.eclipse.org/forums/index.php?t=msg&th=1070518&goto=1709109&#msg_1709109

How to Dynamically adding fields in JSF?

HI All,
I am desperately looking for the assistance on adding and removing the fields and rows using JSF. I am using ICE Faces for the rich UI look. The following is my problem:
I have to add one text box and two buttons (+) and (-) in a row.
When user clicks on the + button, one new row should be added with the above components.
When user clicks on the - button, the corresponding row should be removed from the display.
I am able to add the individual components like text box and remove it. But, here my challenging point is to add and remove as a row. How would I remove that specific row (instance) from the UI View Root.
I have tried several times, but till now I could not find a solution. Please suggest me the possible solutions.
Thanks in advance,
Krishna
Rather use a h:dataTable (or the IceFaces equivalent ice:dataTable) which is backed by a List<Data> contining objects which each represents the data of a single row. On Add just add a new Data item to the list. On Remove just remove the selected Data item from the list.
See also:
How to dynamically add new row to table? - detailed answer to similar question
Using Datatables - shows step by step how to use datatables in JSF 1.x.
CRUD datatable using #ViewScoped - simple example of JSF 2.0 CRUD

Categories