After upgrading to vaadin 24.5.0.alpha1 I saw that Column.setClassNameGenerator is deprecated and Column.setPartNameGenerator should be used instead.
Is there a reason why we can’t have both?
I often use setClassNameGenerator to give the cell specific attributes like “no-padding” or “background”, also often combining them. Assigning these “attributes” via a part feels not right because part should only be one value and not multiple. A class is a better use case for this so I would love to keep this method.
The part names are fetched in a reactive manner, when the respective grid or row is loaded (e.g. due to scrolling or a refresh). Thus the callback has to decide which part names are to be provided.
I understand, in my case I want to give a style to the column of my grid where the cell focus is located, if I change the column I should remove the style from the column and give it to the new column. Is that possible?
In Java I guess the easiest way is to utilize cell focus listener. With that you get the respective column, where the focus event happend. That info you can then use in the part name generator to add an additional name like “focused-column” or so and refresh the grid.
If that is no option due to a “heavy” backend, the alternative would be to do in in the client utilizing JavaScript and the underlying html table of the grid.
I have already implemented the mechanism to give a new CSS part (“focused-column”) to the column in the addCellFocusListener and it works ok. But when selecting another column I must remove the CSS part given to the previous column to give it to the new column and I don’t have mechanisms for that, right?