Row data hight
Row data hight
cuthbe123
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
Without seeing what you have its hard to say. Maybe you need to remove the
nowrap
class from yourtable
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
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
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
that would just put a ... after it, but what I want to do is wrap it onto the line like doing a \n
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
So take this
https://live.datatables.net/cifapuhi/2415/
you see the long name, i want the over two lines or three.
I removed
nowrap
from thetable
tag. Is this what you are looking for?https://live.datatables.net/cifapuhi/2416/edit
Kevin
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
Also you might be able to use
columns.width
to set the desired width.Kevin
Another option:
https://live.datatables.net/cifapuhi/2418/edit
Replace the
20
inmatch(/.{1,20}/g)
with the length of the lines. The words can be broken in the middle.Kevin