The styleProvider for Table can also work with multiple columns. I can advise you to check the names of the properties, maybe you were mistaken.
Perhaps your problem can be solved if you clear the browser cache by pressing CTRL+F5.
Please check that in debug mode the style for chance property is set correctly. To do this, you need to open the Developer tools in the browser (CTRL+SHIFT+I) and go to the Elements tab in Chrome or Inspector tab in Firefox. Then find the chance column and make sure that the style bold ecriture-rouge or another custom style is set.
Example of using a style provider for several columns
The entity Customer has name, age and job properties.
CustomerBrowse
@Install(to = "customersTable", subject = "styleProvider")
protected String customerTableStyleProvider(Customer customer, String property) {
if (property != null) {
if (property.equals("age")) {
Integer age = customer.getAge();
if (age < 20) {
return "young-style";
} else if (age < 40) {
return "old-style";
} else {
return "retiree-style";
}
} else if (property.equals("job")) {
if (customer.getJob().equals("developer")) {
return "developer-style";
} else {
return "another-job-style";
}
}
}
return null;
}
Thank you so much !
I found the problem. Before testing the attribute values, you must test if it is not null. Without this test beforehand, if a null value is present in the column, the column formatting no longer works for the rest of the elements of the table.
@Install(to = "ListeOpportunites", subject = "styleProvider")
protected String etatTableStyleProvider(Opportunite opportunite, String property) {
if (property != null) {
if (property.equals("etat")) {
if (opportunite.getEtat() != null) {
if (opportunite.getEtat() == OpportuniteEtat.EnCours) {
return "bold ecriture-orange";
} else if (opportunite.getEtat() == OpportuniteEtat.Perdue) {
return "bold ecriture-rouge";
} else if (opportunite.getEtat() == OpportuniteEtat.Gagnee) {
return "bold ecriture-lime";
}
}
} else if (property.equals("chance")) {
if (opportunite.getChance() != null) {
if (opportunite.getChance() < 80) {
return "bold ecriture-rouge";
} else if (opportunite.getChance() >= 80 && opportunite.getChance() <= 90) {
return "bold ecriture-orange";
} else if (opportunite.getChance() > 90)
return "bold ecriture-lime";
}
}
}
return null;
}
PS: In your example, if you delete Gray’s age (replace 19 with null), the whole table no longer works.
Thank you for your reply.
I want to apply the same conditions as in the example above. The color should change depending on the value of the aggregate.
With your solution, I don’t see how to do it.
Could you complete your previous example.
With many thanks
too bad, it is useful when it is only the aggregated values that interest us.
Perhaps an evolution to develop.
Again thank you for your advice and help