Skip to content

Commit

Permalink
Revert "Feat: add dropdown menu and adjust column width (#25) (#26)"
Browse files Browse the repository at this point in the history
This reverts commit c3d92b3.
  • Loading branch information
gurdeep330 authored Mar 26, 2024
1 parent 71ebd4d commit 284fdcd
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ table{
}

/* change the with of first column */
thead tr th:first-child,
/* thead tr th:first-child,
tbody tr td:first-child {
width: 400px;
min-width: 300px;
max-width: 400px;
word-break: break-all;
}
} */
74 changes: 70 additions & 4 deletions overrides/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
new DataTable('#table1', {
order: [[5, 'desc']],
"columnDefs": [
{"className": "dt-center", "targets": "_all"}
{"className": "dt-center", "targets": "_all"},
{ width: '30%', targets: 0 }
],
pageLength: 5,
layout: {
Expand All @@ -51,7 +52,8 @@
new DataTable('#table2', {
order: [[3, 'desc']],
"columnDefs": [
{"className": "dt-center", "targets": "_all"}
{"className": "dt-center", "targets": "_all"},
{ width: '30%', targets: 0 }
],
pageLength: 5,
layout: {
Expand All @@ -61,9 +63,41 @@
}
});
new DataTable('#table3', {
initComplete: function () {
this.api()
.columns()
.every(function () {
let column = this;

// Create select element
let select = document.createElement('select');
select.add(new Option(''));
column.footer().replaceChildren(select);

// Apply listener for user change in value
select.addEventListener('change', function () {
column
.search(select.value, {exact: true})
.draw();
});

// keep the width of the select element same as the column
select.style.width = '100%';

// Add list of options
column
.data()
.unique()
.sort()
.each(function (d, j) {
select.add(new Option(d));
});
});
},
// order: [[3, 'desc']],
"columnDefs": [
{"className": "dt-center", "targets": "_all"}
{"className": "dt-center", "targets": "_all"},
{ width: '25%', targets: 1 }
],
pageLength: 5,
layout: {
Expand All @@ -73,9 +107,41 @@
}
});
new DataTable('#table4', {
initComplete: function () {
this.api()
.columns()
.every(function () {
let column = this;

// Create select element
let select = document.createElement('select');
select.add(new Option(''));
column.footer().replaceChildren(select);

// Apply listener for user change in value
select.addEventListener('change', function () {
column
.search(select.value, {exact: true})
.draw();
});

// keep the width of the select element same as the column
select.style.width = '100%';

// Add list of options
column
.data()
.unique()
.sort()
.each(function (d, j) {
select.add(new Option(d));
});
});
},
// order: [[3, 'desc']],
"columnDefs": [
{"className": "dt-center", "targets": "_all"}
{"className": "dt-center", "targets": "_all"},
{ width: '30%', targets: 0 }
],
pageLength: 5,
layout: {
Expand Down
24 changes: 20 additions & 4 deletions templates/overview.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<tbody>
{% for article in most_cited_articles %}
<tr>
<td><a href="{{article.url}}">{{article.title}}</a><br></td>
<td><a href="{{article.url}}">{{article.title}}</a></td>
<td>{{ article.authors}}</td>
<td>{{ article.publicationDate}}</td>
<td>{{ article.journal}}</td>
Expand All @@ -97,7 +97,7 @@
<tbody>
{% for article in most_recent_articles %}
<tr>
<td><a href="{{article.url}}">{{article.title}}</a><br></td>
<td><a href="{{article.url}}">{{article.title}}</a></td>
<td>{{ article.authors}}</td>
<td>{{ article.publicationDate}}</td>
<td>{{ article.journal}}</td>
Expand Down Expand Up @@ -125,14 +125,24 @@
{% for article in manually_curated_articles %}
<tr>
<td>{{ article.topic}}</td>
<td><a href="{{article.url}}">{{article.title}}</a><br></td>
<td><a href="{{article.url}}">{{article.title}}</a></td>
<td>{{ article.authors}}</td>
<td>{{ article.publicationDate}}</td>
<td>{{ article.journal}}</td>
<td>{{ article.citationCount}}</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<th>Topic</th>
<th>Title</th>
<th>Authors</th>
<th>Publication Date</th>
<th>Journal/Conference</th>
<th>Citation count</th>
</tr>
</tfoot>
</table>
</p>

Expand All @@ -149,10 +159,16 @@
{% for article in additional_reading %}
<tr>
<td>{{ article.topic}}</td>
<td><a href="{{article.link}}">{{article.name}}</a><br></td>
<td><a href="{{article.link}}">{{article.name}}</a></td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<th>Topic</th>
<th>Title</th>
</tr>
</tfoot>
</table>
</p>

Expand Down

0 comments on commit 284fdcd

Please sign in to comment.