Skip to content

Commit

Permalink
Bundle name is dt_for_itables
Browse files Browse the repository at this point in the history
Remove documentation on ColReorder
  • Loading branch information
mwouts committed Mar 13, 2024
1 parent 0e64e98 commit 0ea9a9e
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ repos:
rev: v1.14.5
hooks:
- id: jupytext
exclude: dt_package/
exclude: dt_for_itables/
types: ["markdown"]
args: ["--pipe", "isort {} --treat-comment-as-code '# %%' --profile black", "--pipe", "black", "--check", "ruff check {} --ignore E402"]
additional_dependencies:
Expand Down
29 changes: 4 additions & 25 deletions docs/custom_extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@ kernelspec:

# Custom Extensions

## Connected mode

To use custom extensions in the connected mode, you just have to go to the
[download](https://datatables.net/download/) page of DataTables,
select jQuery, DataTable, and the desired extensions, and take a note of the script URL
when using the _CDN_ download method.

Then, you pass this custom URL as either the `dt_url` argument of the
`show` function, or you set it on `opt.dt_url`.
## Internationalisation

```{code-cell}
from itables import show
Expand All @@ -31,20 +23,6 @@ from itables.sample_dfs import get_countries
df = get_countries(html=False)
```

For instance, if you wish to use the [select](https://datatables.net/extensions/select/)
extension in the connected mode, you just have to set `dt_url` according to
the [download](https://datatables.net/download/) page of DataTables, that is:

```{code-cell}
show(
df,
select=True,
dt_url="https://cdn.datatables.net/v/dt/jq-3.7.0/dt-2.0.2/sl-2.0.0/datatables.min.js",
)
```

## Internationalisation

DataTables controls can use a different language than English. To
display the table controls in another language, go to the [internationalisation](https://datatables.net/plug-ins/i18n/)
plug-ins page and find the language URL, like e.g.
Expand Down Expand Up @@ -75,9 +53,9 @@ To use custom extensions in the offline mode, you will need
to create a bundle of jQuery, DataTable, and the desired extensions.

To do so, make a copy of
[`itables/dt_package`](https://github.com/mwouts/itables/tree/main/itables/dt_package):
[`itables/dt_for_itables`](https://github.com/mwouts/itables/tree/main/itables/dt_for_itables):
```bash
$ ls itables/dt_package/
$ ls itables/dt_for_itables/
package.json package-lock.json README.md src.js
```

Expand All @@ -94,6 +72,7 @@ import pdfMake from 'pdfmake';
import DataTable from 'datatables.net-dt';
import 'datatables.net-dt/css/dataTables.dataTables.min.css';

import 'datatables.net-buttons-dt';
import 'datatables.net-buttons/js/buttons.html5.mjs';
import 'datatables.net-buttons/js/buttons.print.mjs';
import 'datatables.net-buttons-dt/css/buttons.dataTables.min.css';
Expand Down
18 changes: 4 additions & 14 deletions docs/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ show(
)
```

## ColReorder
## KeyTable

The [ColReorder](https://datatables.net/extensions/colreorder/) lets you re-order the columns:
With the [KeyTable](https://datatables.net/extensions/keytable/) extension you can navigate in a table using the arrow keys:

```{code-cell}
:tags: [full-width]
show(df, colReorder=True)
show(df, keys=True)
```

```{tip}
Expand All @@ -143,20 +143,10 @@ You can activate this option for all your tables with
~~~python
import itables.options as opt
opt.colReorder = True
opt.keys = True
~~~
```

## KeyTable

With the [KeyTable](https://datatables.net/extensions/keytable/) extension you can navigate in a table using the arrow keys:

```{code-cell}
:tags: [full-width]
show(df, keys=True)
```

```{warning}
The KeyTable extension works in Jupyter Book (try it here in the documentation) but not in JupyterLab.
```
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions itables/html/datatables_template_connected.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<table id="table_id"><thead><tr><th>A</th></tr></thead></table>
<link href="https://cdn.datatables.net/v/dt/jq-3.7.0/dt-2.0.2/datatables.min.css" rel="stylesheet">
<link href="https://www.unpkg.com/dt_for_itables@2.0.1/dt_bundle.css" rel="stylesheet">
<script type="module">
import 'https://cdn.datatables.net/v/dt/jq-3.7.0/dt-2.0.2/datatables.min.js';
import {DataTable, jQuery as $} from 'https://www.unpkg.com/dt_for_itables@2.0.1/dt_bundle.js';

$(document).ready(function () {
document.querySelectorAll("#table_id:not(.dataTable)").forEach(table => {
Expand Down
4 changes: 1 addition & 3 deletions itables/javascript.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,7 @@ def html_table_from_template(
if connected:
output = read_package_file("html/datatables_template_connected.html")
assert dt_url.endswith(".js")
template_url = (
"https://cdn.datatables.net/v/dt/jq-3.7.0/dt-2.0.2/datatables.min.js"
)
template_url = "https://www.unpkg.com/dt_for_itables@2.0.1/dt_bundle.js"
output = replace_value(output, template_url, dt_url)
output = replace_value(
output,
Expand Down
8 changes: 2 additions & 6 deletions itables/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@
warn_on_dom = True

"""The DataTable URL for the connected mode, see https://datatables.net/download/"""
dt_url = (
"https://cdn.datatables.net/v/dt/jq-3.7.0/jszip-3.10.1/dt-2.0.2/"
"b-3.0.1/b-html5-3.0.1/b-print-3.0.1/cr-2.0.0/fc-5.0.0/kt-2.12.0/"
"rg-1.5.0/sb-1.7.0/sp-2.3.0/sl-2.0.0/datatables.min.js"
)
dt_url = "https://www.unpkg.com/dt_for_itables@2.0.1/dt_bundle.js"

"""The DataTable bundle for the offline mode"""
dt_bundle = find_package_file("dt_package/dt_bundle.js")
dt_bundle = find_package_file("dt_for_itables/dt_bundle.js")
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ exclude_lines = [
enable-by-default = true
dependencies = ["hatch-jupyter-builder"]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = ["itables/dt_package/dt_bundle.js", "itables/dt_package/dt_bundle.css"]
ensured-targets = ["itables/dt_for_itables/dt_bundle.js", "itables/dt_for_itables/dt_bundle.css"]

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
path = "itables/dt_package"
path = "itables/dt_for_itables"
build_cmd = "build"
npm = ["npm"]

[tool.hatch.build.targets.sdist]
artifacts = ["itables/dt_package/dt_bundle.js", "itables/dt_package/dt_bundle.css"]
artifacts = ["itables/dt_for_itables/dt_bundle.js", "itables/dt_for_itables/dt_bundle.css"]

[tool.hatch.build.targets.wheel]
artifacts = ["itables/dt_package/dt_bundle.js", "itables/dt_package/dt_bundle.css"]
artifacts = ["itables/dt_for_itables/dt_bundle.js", "itables/dt_for_itables/dt_bundle.css"]

0 comments on commit 0ea9a9e

Please sign in to comment.