Table of Contents

JSON Table Demo

This is example for the JSON Table Plugin.

Simple example

<jsontable id=cars path=cars options='{"colHeaders": ["Year", "Car", "Count"]}'>[
    ["2017", "Honda", 10],
    ["2018", "Toyota", 20],
    ["2019", "Nissan", 30]
]</jsontable>
  • element: jsontable, id: cars_, path: cars, inline data

Advanced example

Table data definition

Add som data into JSON_database.cars:

<json path=cars2>[
    ["BMW",     2017, {"color": {"chassis": "white", "bumper": "white"}}],
    ["Renault", 2015, {"color": {"chassis": "yellow", "bumper": "black"}}],
    ["Tesla",   2018, {"color": {"chassis": "red"}}]
]</json>
  • element: json, path: cars2, inline data

Table options definition

Table options are basically JSON data and can be defined separately:

<json id=table_options_id path=table_options>{
    "colHeaders": ["Car", "Year", "Chassis color", "Bumper color"],
    "columns": [
        {},
        {"type": "numeric"},
        {
            "data": "2.color.chassis"
        },
        {
            "data": "2.color.bumper",
            "width": 100,
            "editor": "select",
            "selectOptions": ["yellow", "red", "black", "white"]
        }
    ],
    "search": true
}</json>
  • element: json, id: table_options__id, path: table_options, inline data

Table

<jsontable> element is first handled by JSON Data Plugin. Attributes 'options' and 'save' are specific. Here is description for all elements:

<jsontable id=cars2 path=cars2 display=all save=diff options=%$table_options%>
{"1":{"2":{"color":{"chassis":"green"}}}}
</jsontable>
[
    [
        "BMW",
        2017,
        {
            "color": {
                "chassis": "white",
                "bumper": "white"
            }
        }
    ],
    [
        "Renault",
        2015,
        {
            "color": {
                "chassis": "yellow",
                "bumper": "black"
            }
        }
    ],
    [
        "Tesla",
        2018,
        {
            "color": {
                "chassis": "red"
            }
        }
    ]
]
[
    [
        "BMW",
        2017,
        {
            "color": {
                "chassis": "white",
                "bumper": "white"
            }
        }
    ],
    [
        "Renault",
        2015,
        {
            "color": {
                "chassis": "green",
                "bumper": "black"
            }
        }
    ],
    [
        "Tesla",
        2018,
        {
            "color": {
                "chassis": "red"
            }
        }
    ]
]
  • element: jsontable, id: cars2_, path: cars2, inline data