It looks like the TemplateRenderer is working. My backend service loads two accounts, and I see two rows in the Grid. Each row contains an (see attached). The issue is that the element is empty:
I’m pretty sure I have the data binding correct, but I wouldn’t be surprised if that part wasn’t working. I am surprised that the <h2> element isn’t rendered inside the <account-card>.
Got into the developer sources tab and check that your dom-module is there and there are no errors present in the developer console.
If it’s not there make sure you are using an @HTMLImport(“account-card.html”) on your AccountCard class to let Vaadin no you want that html loaded into the browser to be used.
If you’ve done that I’d suggest manually checking that your AccountCard class renders properly on its own first to make sure your error is between the AccountCard and the template renderer.
To make it more modular if you add that link to your Account-card class Vaadin will include the file every time the class is used so you can use it anywhere. Just went through all this.
Can you help me giving some snippet code to understand where i’m wrong?
I have a class with a Grid where I add the column to it.
public BehaviorAnalyticsView() {
this.filters.setPlaceHolder("Search...");
this.filters.addActionClickListener(e -> updateGrid(filters));
grid.addColumn(UserCard.getTemplate().withProperty("orderCard", UserCard::create));
}
In the constructor I add the column and then after click on search I execute grid.setItems(result.getResult());
The result is always a sad white page
UserCard is the same that your AccountCard.
In debug mode I can see that all get method are called but nothing appear on my grid.
I added the HtmlImport as suggested but nothing change
@HtmlImport("src/views/analytics/user-card.html")
public class UserCard {
I also included in the Html where the grid is defined.
Where am I doing wrong? I do not know what to do
The result of this code is a Grid of 1 column with 3 rows which cells are consist of Template ‘table-card’. But there is now data in the fields. Here is the screen from developer Sources. All of dom-modules is there and there are no errors present in the developer console.
Sorry for my English!
Hi =)
personal suggestion → stop using the TemplateRender XD
Maybe create a card which extends “Div” and holds other divs and spans and anything you want. This will work perfectly when using grid.addComponentColumn(Card::new).
If you set a clasname to your card, you can style it with CSS
Hi Chris! Thank you for your reply, it will be the plan B =).
Anyway I want to understand how to work with a TemplateRenderer and PolymerTemplates. Could someone help me, please?
If that mistake was somewhere in the code that you shared above, could you share with us what that mistake was, so others can learn from it too? Thanks
If that mistake was somewhere in the code that you shared above, could you share with us what that mistake was, so others can learn from it too? Thanks
Yeah, no problem. I used a wrong property name.
Wrong code:
If that mistake was somewhere in the code that you shared above, could you share with us what that mistake was, so others can learn from it too? Thanks
Yeah, no problem. I used a wrong property name.
Wrong code: