Web/front-end
[DataTables] 선택 한 데이터를 클립보드에 복사하기
hjkongkong
2022. 3. 14. 19:40
[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