Skip to main content

A simple framework for building HTML Tables for Flask

Project description

flask_dtable

flask_dtable a Full-Featured Table System made with Python by Florian Lämmlein

A simple framework for building HTML Tables for Flask.

   


flask_dtable Features

  • HTML forms
  • Column Editor
  • Column replace
  • Includes Datatables
  • Custom column filters
  • Live feedback handler
  • Custom column popups    

How to Install

pip install flask_dtable    


flask_dtable Parameters

Param Description Dict Params Dict Description Type Default Value
data Table content as an list of str list [[]]
 
section Datareplacements by an position index active Status of the current function bool False
position Replacement position as int (by data index) ​list, (int, str ('_sec')) []
value Replacement value as (str or current data value) list, (list, str ('_var')) [[]]
check Data replacement check as function (by data index) list [[]]
 
header Table Header names as an list of str value Table header Names as str list []
class Table header class str None
id Table header id str None
 
footer Table Footer names as an list of str active Status of the current function bool False
value Table footer Names as str list []
class Table footer class str None
id Table footer id str None
calculate Table calculate function by index from column list, int []
decimal_places Table calculate precision numbers int 2
 
form Data Column Editor active Status of the current function bool False
position Form position as int (by data index) ​list, (int, str ('_sec')) []
action From action ​str, list ('_tab', int) None
class From class str None
tooltip_text From submit button tooltip text as str ​list, str []
button_color From submit button color as str ​list, str []
icon From submit button icon as str ​list, str []
request_out Form fields outside the form as list, str dict {}
request_in Form fields inside the form as list, str ​dict {}
 
script Datatables script tag active Status of the current function bool False
responsive Status of the responsive function ​​bool False
fixed Set fixed columns (by data index) int None
order Column orders ([1, 'asc'], [1, 'desc']) ​list, (int, str ('asc', 'desc')) []
length_menu Enable/Disable the length menu bool True
buttons Table buttons as dicts list []
child_rows Child rows as dicts list []
live_feed Live feedback as dicts dict {}
 
editor Tableeditor script tag active Status of the current function bool False
action HTML form action str None
label Editor Modal display Name str None
size Editor Modal display size ('small', 'large') str small
fields Editor fields as dicts list []
order Editor div order as lists list []
chars Editor field value chars replace as functions dict {}
 
popup New window popup on tr click active Status of the current function bool False
url Window main url str None
width Popup window width int 1600
height Popup window height int 1000
params Window url parameters set name as str and value (by data index) list, list (str, int) [[]]
 
 

flask_dtable Special Parameters

Main Param Param Dict Param Description Type Default Value
​form request_out request_name Datafield name list, str []
request_id Datafield id ​list, str []
rquest_value Datafield value (by data index or ('_sec')) ​list, str []
value Datafield replacement value if '_sec' is set ​list, list, str [[]]
check Datafield replacement check as function (by data index) ​list, list, str [[]]
request_out request_name Datafield name list, str []
request_id Datafield id ​list, str []
rquest_value Datafield value (by data index or ('_sec')) ​list, str []
value Datafield replacement value if '_sec' is set ​list, list, str [[]]
check Datafield replacement check as function (by data index) ​list, list, str [[]]
 
script buttons button_name Holds the display name from the buttons str Actions
export Export buttons ('pdf', 'excel', 'csv') ​list, str []
hidde Set the hidde button ​bool False
nohidde Don´t hidde this columns (by column index) list, int []
filter Set the filter button (by column index) list, int []
custom_filter Set custom filters as dicts list, dict []
data_filter Set data filters (creates url get parameters) as dicts list, dict []
custom_filter name Display name from filter str None
labels Display values from filter row list, str []
values Check the values (by the data section as str) list, str []
data_filter name Display name from filter str None
labels Display values from filter row list, str []
values Check the values (by the data section as str) list, str []
child_rows label Display name from child row str None
column Display value from child row (by data index) int None
live_feed label Display name from live feedback str None
column Fallback value from child row (by data index) int 0
update Set data filters (creates ajax post parameters) dict {}
handler Set data filters live handler (creates ajax post) as dicts dict {}
update url Ajax url to an blueprint str None
value Ajax post values (by data index) str None
handler type Ajax update input type str None
post Ajax update post id, name str None
column Ajax update column (by data index) str None
 
editor fields label Display form field name str None
column Display form field value (by column index) int 0
check Field value to check only if type is radio int 1
class Display form field class ​str None
name Display form field name str None
id Display form field id str None
type Display form field type str None
required Field required check ​bool False
disabled Field disabled check ​bool False
hidden Field hidden check ​bool False
order index div order index (How many fields in one div are shown) int 2
index_lower div order index (if index is to short index_lower is active) int 2
class div order classes str col-md-12 col-lg-6
class_lower div order classes (if index_lower is active class_lower is set) str col-md-12 col-lg-12
chars Field replace tags (special characters) as functions {
 ord('ä'):'ae',
 ord('ü'):'ue',
 ord('ö'):'oe'
}
 
 

flask_dtable Examples

Basic usage:

flask_dtable(
    data = [
        ['Niklas', '13.09.2000'],
        ['Peter', '02.11.2001']
    ],
    header = {
        "value": [
            "Name",
            "Geburtstag"
        ]
    }
)

Datatables usage:

flask_dtable(
    data = [
        ['Niklas', '13.09.2000'],
        ['Peter', '02.11.2001']
    ],
    header = {
        "value": [
            "Name",
            "Geburtstag"
        ]
    },
    script = {
        "active": True
    }
)

Datareplacement usage:

flask_dtable(
    data = [
        ['Niklas', '13.09.2000'],
        ['Peter', '02.11.2001']
    ],
    section = {
        "active": True,
        "position": [0, "_sec"],
        "value": [
            ['Kein Geburtstag', ['_var', 1]]
        ],
        "check": [
            ['data[1] == "02.11.2001"']
        ]
    },
    header = {
        "value": [
            "Name",
            "Geburtstag"
        ]
    },
    script = {
        "active": True
    }
)

Data editor usage:

flask_dtable(
    data = [
        ['Niklas', '13.09.2000'],
        ['Peter', '02.11.2001']
    ],
    header = {
        "value": [
            "Name",
            "Geburtstag"
        ]
    },
    script = {
        "active": True
    },
    editor = {
        "active": True,
        "fields": [
            {
                "label": "Name", 
                "column": 0, 
                "disabled": True
            },
            {
                "label": "Geburtstag", 
                "column": 1, 
                "required": True
            }
        ]
    }
)

Child rows usage:

flask_dtable(
    data = [
        ['Niklas', '13.09.2000', 'Hallo Welt 1'],
        ['Peter', '02.11.2001', 'Hallo Welt 2']
    ],
    header = {
        "value": [
            "Name",
            "Geburtstag"
        ]
    },
    script = {
        "active": True,
        "child_rows": [
            {
                "label": "Zusatz",
                "column": 2
            }
        ]
    }
)

Datatable order usage:

flask_dtable(
    data = [
        ['Niklas', '13.09.2000', 'Hallo Welt 1'],
        ['Peter', '02.11.2001', 'Hallo Welt 2']
    ],
    header = {
        "value": [
            "Name",
            "Geburtstag",
            "Zusatz"
        ]
    },
    script = {
        "active": True,
        "order": [
            [0, 'asc'],
            [1, 'asc']
        ]
    }
)

Datatable button usage:

flask_dtable(
    data = [
        ['Niklas', '13.09.2000', 'Hallo Welt 1'],
        ['Peter', '02.11.2001', 'Hallo Welt 2']
    ],
    header = {
        "value": [
            "Name",
            "Geburtstag",
            "Zusatz"
        ]
    },
    script = {
        "active": True,
        "buttons": {
            "export": ['pdf', 'excel']
        }
    }
)

Datatable filter button usage:

flask_dtable(
    data = [
        ['Niklas', '13.09.2000', 'Hallo Welt 1'],
        ['Peter', '02.11.2001', 'Hallo Welt 2']
    ],
    header = {
        "value": [
            "Name",
            "Geburtstag",
            "Zusatz"
        ]
    },
    script = {
        "active": True,
        "buttons": {
            "filter": [0,2]
        }
    }
)

Datatable filter button with custom filter usage:

flask_dtable(
    data = [
        ['Niklas', '13.09.2000', 'Hallo Welt 1'],
        ['Peter', '02.11.2001', 'Hallo Welt 2']
    ],
    header = {
        "value": [
            "Name",
            "Geburtstag",
            "Zusatz"
        ]
    },
    script = {
        "active": True,
        "buttons": {
            "custom_filter": [
                {
                    "name": "Geburtstag",
                    "labels": ["November"],
                    "values": ["data[1].split('.')[1] == '11'"]
                }
            ]
        }
    }
)

Datatable filter button with data filter usage:

flask_dtable(
    data = [
        ['Niklas', '13.09.2000', 'Hallo Welt 1'],
        ['Peter', '02.11.2001', 'Hallo Welt 2']
    ],
    header = {
        "value": [
            "Name",
            "Geburtstag",
            "Zusatz"
        ]
    },
    script = {
        "active": True,
        "buttons": {
            "data_filter": [
                {
                    "name": "Geburtstag",
                    "labels": ["November", "Dezember"],
                    "values": ["11", "12"]
                }
            ]
        }
    }
)

Form basic usage:

flask_dtable(
    data = [
        ['Niklas', '13.09.2000'],
        ['Peter', '02.11.2001']
    ],
    header = {
        "value": [
            "Name",
            "Geburtstag",
            "Action:"
        ]
    },
    form = {
        "active": True,
        "action": "/submit_page",
        "position": 2,
        "request_in": {
            "request_name": "name",
            "request_value": 0
        }
    },
    script = {
        "active": True
    }
)

Form data replacement usage:

flask_dtable(
    data = [
        ['Niklas', '13.09.2000'],
        ['Peter', '02.11.2001']
    ],
    header = {
        "value": [
            "Name",
            "Geburtstag",
            "Action:"
        ]
    },
    form = {
        "active": True,
        "action": "/submit_page",
        "position": 2,
        "request_in": {
            "request_name": ["name", "birthday"],
            "request_value": [0, "_sec"]
        },
        "value": [
            ["Kein Geburtstag", ["_var", 1]]
        ],
        "check": [
            ["data[1] == '02.11.2001'"]
        ]
    },
    script = {
        "active": True
    }
)

Live feedback usage:

flask_dtable(
    data = [
        ['Niklas', '13.09.2000'],
        ['Peter', '02.11.2001']
    ],
    header = {
        "value": [
            "Name",
            "Geburtstag"
        ]
    },
    script = {
        "active": True,
        "live_feed": {
            "label": "Mein Geburtstag",
            "column": 1,
            "update": {
                "url": "preview",
                "value": [
                    {"post": "birthday", "column": 1}
                ]
            }
        }
    }
)

Popup usage:

flask_dtable(
    data = [
        ['Niklas', '13.09.2000'],
        ['Peter', '02.11.2001']
    ],
    header = {
        "value": [
            "Name",
            "Geburtstag"
        ]
    },
    popup = {
        "active": True,
        "url": "/edit",
        "params": [
            ["birthday", 1]
        ]
    }
)

   


Legacy versions

This version of the flask_dtable are the acctual stable version which is compatible with Python 3+ and is supported for feature updates.

Do you have any Ideas, Changes or Bugs ?

Please let me know in the Comments, i will try to fix or add waht you found/want :D

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_dtable-1.0.0.tar.gz (21.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page