Skip to content

API Examples

This page demonstrates usage of the APIs.

Export JSON Button

TIP

extend: Extend json
text: Rename the text as desired JSON
filename: Rename the filename as desired json-filename

js
<script type="text/javascript" src="../src/button-json.js"></script>
<script type="text/javascript">
    $('#example').DataTable( {
        dom: "Bflrtip",
        responsive: true,
        select: true,
        colReorder: true,
        dom: 'Bfrtip',
        buttons: [
            {
                extend: 'json',
                text: 'JSON',
                filename: "json-filename",
            },
        ],
        columns: [
            { title: 'Name' },
            { title: 'Position' },
            { title: 'Office' },
            { title: 'Age' },
            { title: 'Start Date' },
            { title: 'Salary' },
            { title: 'URL' },
          ],
    });
</script>

Render URL

TIP

urlRenderObj: Function will change the display of data as HTML a tag for URL to open in new tab

js
<script type="module">
    import { urlRenderObj } from '../src/url-render.js'
	$('#example').DataTable( {
        dom: "Bflrtip",
        responsive: true,
        select: true,
        colReorder: true,
        dom: 'Bfrtip',
        buttons: [
            {
                extend: 'json',
                text: 'JSON',
                filename: "json-filename",
            },
        ],
        columns: [
            { title: 'Name' },
            { title: 'Position' },
            { title: 'Office' },
            { title: 'Age' },
            { title: 'Start Date' },
            { title: 'Salary' },
            { title: 'URL', ...urlRenderObj("URL") },
          ],
    });
</script>