Row data hight

Row data hight

cuthbe123cuthbe123 Posts: 10Questions: 3Answers: 0

Hi, we have data in a table but we want the row to grow to fit the data rather than scroll. Is that possible?

Answers

  • kthorngrenkthorngren Posts: 20,142Questions: 26Answers: 4,736

    Without seeing what you have its hard to say. Maybe you need to remove the nowrap class from your table tag. See the Styling docs for details. You should be able to apply standard styling to the table to display it the way you want. If you need help with this please post a link to your page or a test case replicating your environment so we can offer suggestsion.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

  • cuthbe123cuthbe123 Posts: 10Questions: 3Answers: 0

    So whats happening is if I have a log line in a column like this

    2023-03-15 14:00:35.419 INFO [KafkaConsumer:ben-cuthbert-local-lon-baseserver-appnode-thread-1] com.celertech.baseserver.node.ApplicationNodeKafkaClusterEndpoint - ApplicationNodeIdentifier [subsystem=supervisor, node=supervisor-node] -> 2023-03-15T14:00:35.419Z

    That is showing in the column but it makes the column very long like 1248px but what I want is it to wrap the text in the column or say 3 lines so the user does not have to scroll to the right on each line

  • kthorngrenkthorngren Posts: 20,142Questions: 26Answers: 4,736

    You can use a renderer may like this ellipsis renderer. Or you can use columns.render to breakup the line in a way that makes sense.

    Kevin

  • cuthbe123cuthbe123 Posts: 10Questions: 3Answers: 0

    that would just put a ... after it, but what I want to do is wrap it onto the line like doing a \n

  • kthorngrenkthorngren Posts: 20,142Questions: 26Answers: 4,736

    Use columns.render to split the line where it makes sense with <br> for the newline character. Here is a very simple example:
    https://live.datatables.net/horunera/1/edit

    You will probably want something a bit more sophisticated to split the line where is makes sense.

    Kevin

  • cuthbe123cuthbe123 Posts: 10Questions: 3Answers: 0

    So take this
    https://live.datatables.net/cifapuhi/2415/
    you see the long name, i want the over two lines or three.

  • kthorngrenkthorngren Posts: 20,142Questions: 26Answers: 4,736

    I removed nowrap from the table tag. Is this what you are looking for?
    https://live.datatables.net/cifapuhi/2416/edit

    Kevin

  • kthorngrenkthorngren Posts: 20,142Questions: 26Answers: 4,736
    edited March 2023

    I should add that dt-body-nowrap means the column won't wrap. Opposite of what you are asking for. See the cell styling docs.

    Kevin

  • kthorngrenkthorngren Posts: 20,142Questions: 26Answers: 4,736

    Also you might be able to use columns.width to set the desired width.

    Kevin

  • kthorngrenkthorngren Posts: 20,142Questions: 26Answers: 4,736
    edited March 2023

    Another option:
    https://live.datatables.net/cifapuhi/2418/edit

    Replace the 20 in match(/.{1,20}/g) with the length of the lines. The words can be broken in the middle.

    Kevin

Sign In or Register to comment.