Determine maximum height of a column title in Primefaces

Asked

Viewed 704 times

4

I would like to know if it is possible to do the following:

I need in a datatable define a maximum height of a column. Because there are some that the text gets too long and the column value is a Yes or No, so the title gets too big. Then I thought about the possibility of breaking the title, but with a maximum height. So the text would be the size that would be ideal.

inserir a descrição da imagem aqui

  • Just to make sure before proceeding with any response: this image displays the desired result?

  • No. That’s what I don’t want, I’d like to limit it to a maximum of three lines in height. Problem that I realized that then use the onDemand of the first faces it can get all broken, the title in relation to the contents of the column.

  • Even before answering... From what I see a solution would be to increase the width in such a way that we had at most 3 lines. And on the other hand, if they are dynamic columns, then the thing can complicate a little more, between so much you would have to limit to a fixed height, a considerable width and a certain limit of characters. My opinion. What do you think?

  • Friend what is missing on the other side of this message is knowledge, rs. But the following I managed to do this by greatly increasing the table width stipulated a percentage value far above the dialog I use to display, so yes I managed to control the size of the columns problem is that the feature of the datatable onDemand it the times of the stick, I saw other users complaining about it too.

  • I didn’t understand that "Friend what is missing on the other side of that message is knowledge, rs." you could explain @Macario1983?

  • When you say limit to the maximum length of characters

  • Ham, okay! So there’s no knowledge about the maximum amount of characters? Okay, if the subject has already been resolved, could you answer the question itself bro.

  • Just so I understand when it comes to maximum characters, it would be to fill a test field with as much as it supports and then yes adjust?

  • Well, I thought there might be an estimate of a maximum text for the columns (e.g., 90), and knowing that, you would adjust a maximum width (using max-width CSS) of the column in such a way that it would support at most 3 lines. I know it would be an aggressive way to solve it, but we could consider it a last chance.

  • 1

    Um, I understood that you would have some dynamic algorithm that recognizes the contents of a cell and adjusts the width

  • Um, another interesting suggestion! I think it would be less rude than the one I proposed.

  • Problem is doing that

  • The columns have the attribute "width" and the same could receive the vallor defined by the "determinaTamanho" method that receives as parameter the header text. Then it would be knowing only the ratio of x characters to y pixels. what do you think?

  • I thought of something like finding a pixel multiplication * characters. But wouldn’t that slow down the page?

  • Well, slow I do not believe, it would not be the most efficient thing in the world, more intuitively I believe it would not slow (it would be a very simple algebraic operation). I advise you to try it anyway.

  • Could you post the current code in a generalized way? It would help a lot in preparing a response.

Show 11 more comments

1 answer

0

To do what you asked just set max-height in the Stilo of your column by setting the maximum size in pixels.

<p:column ... style="max-height: 50px" >

But in the case you quoted above I would recommend putting an abbreviation in the header line and in the title property would put the full text. This way when the user hovers over the header the full text will appear. Ex:

<h:outputText value="Pode alterar" title="Permissão para alterar os dados cadastrais do cliente" />

Browser other questions tagged

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