| 1 |
// DATA_TEMPLATE: empty_table |
| 2 |
oTest.fnStart( "Row ids" ); |
| 3 |
|
| 4 |
$(document).ready( function () { |
| 5 |
var table = $('#example').DataTable( { |
| 6 |
"ajax": "../../../examples/ajax/data/objects.txt", |
| 7 |
"deferRender": true, |
| 8 |
"rowId": 'name', |
| 9 |
"columns": [ |
| 10 |
{ "data": "name" }, |
| 11 |
{ "data": "position" }, |
| 12 |
{ "data": "office" }, |
| 13 |
{ "data": "extn" }, |
| 14 |
{ "data": "start_date" }, |
| 15 |
{ "data": "salary" } |
| 16 |
] |
| 17 |
} ); |
| 18 |
|
| 19 |
/* Basic checks */ |
| 20 |
oTest.fnWaitTest( |
| 21 |
"Table draws", |
| 22 |
null, |
| 23 |
function () { return $('tbody td:eq(0)').text() === 'Airi Satou'; } |
| 24 |
); |
| 25 |
|
| 26 |
oTest.fnTest( |
| 27 |
"First row has an ID assigned", |
| 28 |
null, |
| 29 |
function () { return $('tbody tr:eq(0)').attr('id') === 'Airi Satou'; } |
| 30 |
); |
| 31 |
|
| 32 |
oTest.fnTest( |
| 33 |
"Can select first row by ID via API", |
| 34 |
null, |
| 35 |
function () { return table.row('#Airi Satou').data().name === 'Airi Satou'; } |
| 36 |
); |
| 37 |
|
| 38 |
oTest.fnTest( |
| 39 |
"Can select second row by ID via API", |
| 40 |
null, |
| 41 |
function () { return table.row('#Angelica Ramos').data().extn === '5797'; } |
| 42 |
); |
| 43 |
|
| 44 |
oTest.fnTest( |
| 45 |
"Can select 11th row (deferred rendering) by ID via API - node doesn't exist", |
| 46 |
null, |
| 47 |
function () { return table.row('#Charde Marshall').data().extn === '6741'; } |
| 48 |
); |
| 49 |
|
| 50 |
oTest.fnTest( |
| 51 |
"Get id for a row", |
| 52 |
null, |
| 53 |
function () { return table.row('#Dai Rios').id() === 'Dai Rios'; } |
| 54 |
); |
| 55 |
|
| 56 |
oTest.fnTest( |
| 57 |
"Get id for a row with a hash", |
| 58 |
null, |
| 59 |
function () { return table.row('#Dai Rios').id(true) === '#Dai Rios'; } |
| 60 |
); |
| 61 |
|
| 62 |
oTest.fnTest( |
| 63 |
"Get ids for a rows", |
| 64 |
null, |
| 65 |
function () { |
| 66 |
return JSON.stringify(table.rows([':eq(0)', ':eq(1)']).ids().toArray()) === '["Airi Satou","Angelica Ramos"]'; |
| 67 |
} |
| 68 |
); |
| 69 |
|
| 70 |
oTest.fnTest( |
| 71 |
"Get ids for a rows with a hash", |
| 72 |
null, |
| 73 |
function () { |
| 74 |
return JSON.stringify(table.rows([':eq(0)', ':eq(1)']).ids(true).toArray()) === '["#Airi Satou","#Angelica Ramos"]'; |
| 75 |
} |
| 76 |
); |
| 77 |
|
| 78 |
|
| 79 |
oTest.fnComplete(); |
| 80 |
} ); |