Skip to content

Commit 9fa79e2

Browse files
committed
adding drop-down
1 parent 8a2a167 commit 9fa79e2

File tree

1 file changed

+47
-37
lines changed

1 file changed

+47
-37
lines changed

qiita_pet/templates/redbiom.html

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
$("#redbiom-table").dataTable({
1414
"dom": 'lfrt<"footer">ip',
1515
'footerCallback': function ( row, data, start, end, display ) {
16+
17+
// adding total features found
18+
1619
var api = this.api(), data;
1720
var total_features = api
1821
.column(4)
@@ -30,34 +33,40 @@
3033
}
3134
}
3235
$('.footer').html(text)
36+
37+
// adding selectors for filtering
38+
39+
this.api().columns().every( function (iterator) {
40+
var column = this;
41+
if (iterator == 3 && column.data().length != 0) {
42+
var select = $('<select><option value=""></option></select>')
43+
.appendTo( $(column.footer()).empty() )
44+
.on('change', function () {
45+
var val = $.fn.dataTable.util.escapeRegex( $(this).val() );
46+
column
47+
.search( val ? '^'+val+'$' : '', true, false )
48+
.draw();
49+
});
50+
var added = [];
51+
column.data().each(function (d){
52+
var cmd = d.command;
53+
if (added.indexOf(cmd) == -1){
54+
added.push(cmd);
55+
select.append('<option value="' + cmd + '">' + cmd + '</option>');
56+
}
57+
});
58+
}
59+
});
3360
},
3461
"columns": [
3562
{ "data": null, "orderable": false, "width": "10%" },
3663
{ "data": null, "width": "40%" },
37-
{ "data": "aname", "width": "20%" },
38-
{ "data": null, "width": "20%" },
64+
{ "data": null, "width": "10%" },
65+
{ "data": null, "width": "30%" },
3966
{ "data": null, "width": "10%" }
4067
],
41-
"order": [[ 3, 'asc' ]],
42-
// "displayLength": 25,
43-
"drawCallback": function ( settings ) {
44-
var api = this.api();
45-
var rows = api.rows( {page:'current'} ).nodes();
46-
var last=null;
47-
48-
api.column(3, {page:'current'} ).data().each( function ( data, i ) {
49-
group = data.command;
50-
if ( last !== group ) {
51-
$(rows).eq( i ).before(
52-
'<tr class="group"><td colspan="5">'+group+'</td></tr>'
53-
);
54-
last = group;
55-
}
56-
});
57-
},
5868
columnDefs: [
59-
{ "visible": false, "targets": 3 },
60-
{ type:'natural', targets: [1,2,4] },
69+
{ type:'natural', targets: [1,2,3,4] },
6170
// render Add to Analysis button
6271
{"render": function ( data, type, row, meta ) {
6372
var text = '';
@@ -88,6 +97,10 @@
8897
return text;
8998
}, targets: [2]},
9099
// render # of samples/categories
100+
{"render": function ( data, type, row, meta ) {
101+
return row.command;
102+
}, targets: [3]},
103+
// render # of samples/categories
91104
{"render": function ( data, type, row, meta ) {
92105
return row.samples.length;
93106
}, targets: [4]}
@@ -127,35 +140,23 @@
127140
var header_0 = "";
128141
{% end %}
129142
var header_2 = "Artifact Name";
130-
var header_3 = "# of Samples Found";
143+
var header_4 = "# of Samples";
131144
if (search_on == 'categories') {
132145
header_2 = "Metadata Categories";
133-
header_3 = "# of Categories Found";
146+
header_4 = "# of Categories";
134147
}
135148
$('#redbiom-table tr:eq(0) th:eq(0)').text(header_0);
136149
$('#redbiom-table tr:eq(0) th:eq(1)').text("Study Title");
137150
$('#redbiom-table tr:eq(0) th:eq(2)').text(header_2);
138-
$('#redbiom-table tr:eq(0) th:eq(3)').text(header_3);
151+
$('#redbiom-table tr:eq(0) th:eq(3)').text("Processing Parameters");
152+
$('#redbiom-table tr:eq(0) th:eq(4)').text(header_4);
139153

140154
redbiom_table.rows.add(data.data).draw();
141155
redbiom_info.html('');
142156
}
143157
}
144158
});
145159
});
146-
147-
// Order by the grouping
148-
$('#redbiom-table tbody').on( 'click', 'tr.group', function () {
149-
var table = $('#redbiom-table').DataTable();
150-
var currentOrder = table.order()[0];
151-
if (currentOrder[0] === 3 && currentOrder[1] === 'asc') {
152-
table.order([ 3, 'desc' ]).draw();
153-
}
154-
else {
155-
table.order([ 3, 'asc' ]).draw();
156-
}
157-
});
158-
159160
});
160161
</script>
161162

@@ -199,6 +200,15 @@
199200
<th></th>
200201
</tr>
201202
</thead>
203+
<tfoot>
204+
<tr>
205+
<th></th>
206+
<th></th>
207+
<th></th>
208+
<th></th>
209+
<th></th>
210+
</tr>
211+
</tfoot>
202212
</table>
203213
</div>
204214

0 commit comments

Comments
 (0)