2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

DataTablesにおけるTD要素のellipsisについて

Last updated at Posted at 2019-08-02

これは何?

これを
ss01.PNG
こんな風にしたいんですよ。
ss02.PNG

やり方ググる

本家的にはコレっぽい。でもコレだと文字数依存になるので今回は違う。
https://datatables.net/blog/2016-02-26

こっちはヒントになりそうだなぁ。
https://codeday.me/jp/qa/20190101/101577.html

やってみよう

まずは必要な列にclass属性付けて…

JavaScript
$('table').DataTable({
  columnDefs: [
    { targets: [6, 7, 8], className: 'ellipsis' }
  ]
});

そのclassにCSSを設定すれば…

CSS
td.ellipsis {
  overflow-x: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 10rem;
}

できた。
ss02.PNG
もうググりたくない。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?