Format word if it is in a datatable

Asked

Viewed 83 times

1

Given my datatable:

inserir a descrição da imagem aqui

Mark the word Atack. Is it possible to create a check that if this word is in the datatable it gets a different format? Ex: Bold and the color is Blue.

  • The word Atack you want to style it appears only in the column "Increase" ?

1 answer

1


I think you can create a style this way: .atack { background-image: none !important; color: blue !important; font-weight: bold; width: 100%!imporant; height: 100%!imporant; } And in the outputText you want to modify puts the check: styleClass="#{valor.toLowerCase().indexOf('atack')!= -1 ? 'atack':''}" In case you wanted to modify only the word atack, could then create a method in the beam and check if the value contains the word, not if it would be a good practice do so:
public String contemAtack(String val) { //remova os espaços entre < b e < f e < /font e < /b return val.replace("Atack", < b>< font color=#0080c0>Atack< /font>< /b>); }
And in datatable would add the check in the desired columns: < h:outputText value="#{seuBeam.contemAtack(valor)}" escape="false" />

  • Your first suggestion was great, but I have more words to format with different formatting. What would you indicate me?

  • What does -1 mean in condition ?

  • is the index, that is, if it is different from -1 then the word contains in the string

Browser other questions tagged

You are not signed in. Login or sign up in order to post.