Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Adding combobox column to grid
Is it required to use renderer to be able to add combobox to grid in vaadin? Really I am new to java vaadin and do not know well about the renderer. Anyway: I need a help to add a column that contains the combobox (which contains the values: "Approve" and "Reject") in the grid but until now I am failing and seems my using for renderer is wrong specially I do not know how to configure the ComponentRenderer (is it required to add it as class, how?) and the needed packages to be included.
Looking for your kindly help. Regards Bilal
Which Vaadin version are you using? 7, 8 and 10+ all work differently in this case.
I checked maven and I found the following:
<dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-shared</artifactId> <version>7.6.5</version> </dependency> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-client</artifactId> <version>7.6.5</version> </dependency> <dependency> <groupId>com.vaadin</groupId> <artifactId>vaadin-themes</artifactId> <version>7.6.5</version> </dependency> <dependency> <groupId>com.vaadin.addon</groupId> <artifactId>vaadin-charts</artifactId> <version>3.2.0</version> </dependency>
So I see it is version 7.
Appreciate the kindly help. Regards Bilal
Thank you Olli for your kindly help. The problem that I am facing it: I am not able to
import de.datenhahn.vaadin.ComponentRenderer; the compiler is not see it and that is why I can not use
ComponentRenderer(). I added the dependency and the repository to the pom.xml as described in the link. In other words: I am not able to import any of the packages mentioned in the below link: https://vaadin.com/directory/component/componentrenderer/1.0.3/api So do I miss any thing? Do I import wrongly or I am missing something to be done at maven? Regards Bilal
Did you run the
install Maven goals?
Thank you Olli. I did Maven Clean and Maven Install from Run As and still the same problem, I am not able to import de.datenhahn.vaadin.componentrenderer to the class as shown in the attachment. By the way, I added the required dependency and repository in the pom.xml file but each one under its context (the repository is added under repositories context and the dependency is added under dependencies context). What could be the reason that I am not able to import the class? I am sure it is not downloaded by maven. Regards Bilal
Can you share your full pom.xml?
I attached the two pom files as the workspace contains two projects as shown in the attachments. And I added the dependency and the repository in two pom files (also I tried to add them for the pom of the project that I need to use the ComponentRenderer inside it, but the same result).
Appreciate your kindly help and advise.
I think, I found the reason for the problem. It could be related to the internal repository. I found this error and I attached it for you. Although I added the repository that is given in the ComponentRenderer link, but still there is a problem to find it.
Sounds like a problem with an internal repository that you'll need to sort out; the pom.xml seems ok by a quick glance.
Thank you Olli. Yes I think so, but what could be the reason to depends on the internal repository and I added the required repository in the pom.xml? In other words, why it is not taking what I added in the pom as repository? Regards Bilal
Might be that there are restrictions placed on your network access, so that you can't e.g. directly download things from Maven Central.
In my network, I can reach anywhere and no restrictions. But maybe there is restrictions in the maven local repository that avoid me from downloading things from maven central directly. I need to check with the team to know what they did in the maven local repository and will come back for you for sure. Regards Bilal
Until they resolve the local repository for maven, do you have an idea how to add them manually for the project if I downloaded them as ZIP file from this link: https://static.vaadin.com/directory/user55298/addon/file6941695817906551230_componentrenderer-1.0.3.zip
From this website: https://vaadin.com/directory/component/componentrenderer/1.0.3
I attached what the extract contains. The META-INF directory contains MANIFEST.MF file, so where I can place these files in the workspace so I can import the required packages to be used.
OK Olli, I was able to add the jar file as reference library to the Build Path and then I was able to
import de.datenhahn.vaadin.componentrenderer.*; and it accepted new ComponentRenderer() in the code. But now the grid appears empty !
Kindly find the attach documents. Could be because of the jar that I added, as I have to add the MANIFEST.MF file? But where to add?
Can you help why the grid is appearing blank when using the ComponentRenderer for the combo box column?
Based on that information, not really. You should test the demo project from the add-on and see how that is working and see what you're doing differently.
Thank You Olli.
Is it possible to add ComboBox using addComponentColumn? But I am not able to use it because it is not appearing under the grid. Do I need to import certain package to be able to use addComponentColumn? My vaadin version is 7.6, maybe this is the reason why I can not see addComponentColumn?
I need really any method to be able to add the ComboBox in the grid !
addComponentColumn is Vaadin 8
Thank you Olli. I can not upgrade for vaadin 8 for the time being. Is there any other method other than ComponenetRenderer that can be used to let the ComboBox appears in the grid?
You could try SelectRenderer instead: https://vaadin.com/directory/component/selectrenderer
It's not quite the same as a ComboBox, but it could work.