相关连接
Features Data Callbacks Options Internationalisation
Columns - 列配置部分
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var table = $('#example').DataTable({
"columns": [{
"cellType": "td",
"className": "my_class",
"contentPadding": "mmm",
"createdCell": function(td, cellData, rowData, row, col) {
if (cellData < 1) {
$(td).css('color', 'red')
}
},
"data": "engine",
"defaultContent": "<i>Not set</i>",
"name": "engine",
"orderable": true,
"orderData": [0, 1],
"orderDataType": "dom-text",
"orderSequence": ["asc"],
"render": function(data, type, full, meta) {
return '<a href="' + data + '">Download</a>';
},
"searchable": true,
"title": "My column title",
"type": "html",
"visible": true,
"width": "20%",
}]
});
var table = $('#example').DataTable({
"columnDefs": [{
"targets": 0,
"cellType": "td",
"className": "my_class",
"contentPadding": "mmm",
"createdCell": function(td, cellData, rowData, row, col) {
if (cellData < 1) {
$(td).css('color', 'red')
}
},
"data": "engine",
"defaultContent": "<i>Not set</i>",
"name": "engine",
"orderable": true,
"orderData": [0, 1],
"orderDataType": "dom-text",
"orderSequence": ["asc"],
"render": function(data, type, full, meta) {
return '<a href="' + data + '">Download</a>';
},
"searchable": true,
"title": "My column title",
"type": "html",
"visible": true,
"width": "20%",
}]
});
PS:以上代码无任何实际使用价值,纯粹演示对象结构,和新版参数的写法