blog
[DataTables] 선택 한 데이터를 클립보드에 복사하기 본문
[DataTables] row Select 기능 추가(선택한 행의 data 값 가져오기)
DataTables에서 아주 간단하게 기능을 추가할 수 있다. https://datatables.net/download/index 이렇게 네개 추가 $('#dataTable').DataTable({ select: true }); 공식에서 다양한 select 기능을 제공한다. http..
hjkongkong.tistory.com
[DataTables] row Select 기능 추가(선택한 행의 data 값 가져오기)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// select check
$('#dataTable tbody').on('click', 'tr', function() {
this_row = table.rows(this).data();
//alert("모든 데이터: " + table.row(this).data() +
//" name : " + this_row[0][0] + " office:" + this_row[0][2]);
const textArea = document.createElement('textarea'); //복사를 위한 textarea 생성
textArea.textContent = "name : " + this_row[0][0] + " office:" + this_row[0][2];
document.body.append(textArea); // body에 textArea 그림
textArea.select();
document.execCommand("copy");
textArea.remove();
alert("클립보드 복사 완료")
});
|
cs |
복사 된 결과 값
name : Brielle Williamson office:New York
'Web > front-end' 카테고리의 다른 글
[Javascript] 앞글자가 ~으로 시작하는 element의 id 찾기 (0) | 2022.03.14 |
---|---|
[iframe] 도메인이 다른 부모-자식 창 간의 통신 (0) | 2022.03.14 |
alert [object Object] (0) | 2022.03.14 |
[DataTables] row Select 기능 추가(선택한 행의 data 값 가져오기) (0) | 2022.03.05 |
[DataTables] column grouping (0) | 2022.02.26 |