def test_szng004_on_focus(test, props, data_fn): app = dash.Dash(__name__) baseProps1 = get_props(data_fn=data_fn) baseProps2 = get_props(data_fn=data_fn) baseProps1.update(dict(**props, id="table1")) baseProps2.update(dict(**props, id="table2")) app.layout = Div( [ DataTable(**baseProps1), DataTable(**baseProps2), ] ) test.start_server(app) table2 = test.table("table2") for i in range(len(baseProps1.get("columns"))): table2.cell(0, i).click() t1 = test.driver.find_element_by_css_selector("#table1") t2 = test.driver.find_element_by_css_selector("#table2") cells_are_same_width(t1, t1) cells_are_same_width(t1, t2) assert test.get_log_errors() == []
def get_app(props, data_fn=generate_mock_data): app = dash.Dash(__name__) baseProps = get_props(data_fn=data_fn) baseProps.update(props) app.layout = DataTable(**baseProps) return app
def get_app(props=dict()): app = dash.Dash(__name__) baseProps = get_props() baseProps.update(props) app.layout = DataTable(**baseProps) return app
def get_app(props=dict()): app = dash.Dash(__name__) baseProps = get_props() baseProps.update( dict(columns=[dict(c, hideable="last") for c in baseProps["columns"]])) baseProps.update(props) app.layout = DataTable(**baseProps) return app
def get_app(props=dict()): app = dash.Dash(__name__) baseProps = get_props() for i in range(len(baseProps["data"])): datum = baseProps["data"][i] if datum["eee"] % 2 == 0: datum.pop("eee") elif datum["eee"] % 10 == 5: datum["eee"] = "xx-{}-xx".format(datum["eee"]) for c in baseProps["columns"]: if c["id"] == "rows": c.update(dict(format=dict(specifier=".^5"))) elif c["id"] == "ccc": c.update( dict( format=dict( locale=dict(seperate_4digits=False), prefix=1000, specifier=".3f", ) ) ) elif c["id"] == "ddd": c.update( dict( format=dict( locale=dict(symbol=["eq. $", ""], seperate_4digits=False), nully=0, specifier="$,.2f", ), on_change=dict(action="coerce", failure="default"), validation=dict(allow_nully=True), ) ) elif c["id"] == "eee": c.update( dict( format=dict(nully="N/A", specifier=""), on_change=dict(action="coerce", failure="default"), ) ) baseProps.update(dict(filter_action="native")) baseProps.update(props) app.layout = DataTable(**baseProps) return app
def get_app(props=dict(), data_fn=generate_mock_data): app = dash.Dash(__name__) baseProps = get_props(data_fn=data_fn) for c in baseProps.get("columns"): c.update(dict(on_change=dict(action="coerce", failure="reject"))) baseProps.update(props) app.layout = DataTable(**baseProps) return app
def get_app(editable): app = dash.Dash(__name__) baseProps = get_props() baseProps.update(dict(editable=editable)) if editable: for c in baseProps["columns"]: c["editable"] = not c["id"] in ["bbb", "eee", "fff"] app.layout = DataTable(**baseProps) return app
def get_app( props=dict(), data_fn=generate_markdown_mock_data, assets_folder=None): app = (dash.Dash(__name__) if assets_folder is None else dash.Dash( __name__, assets_folder=assets_folder)) baseProps = get_props(data_fn=data_fn) baseProps.update(dict(filter_action="native", sort_action="native")) baseProps.update(props) app.layout = DataTable(**baseProps) return app
def get_sigle_row_app(props=dict()): app = dash.Dash(__name__) baseProps = get_props() baseProps.update( dict(columns=[ dict(c, hideable=True, name=c["id"]) for c in baseProps["columns"] ])) baseProps.update(props) app.layout = DataTable(**baseProps) return app
def get_app(props=dict(), special=False, clear=False): app = dash.Dash(__name__) baseProps = get_props(rows=200) if special: for c in baseProps.get("columns"): if c["id"] == "bbb": c["id"] = "b+bb" elif c["id"] == "ccc": c["id"] = "c cc" elif c["id"] == "ddd": c["id"] = "d:dd" elif c["id"] == "eee": c["id"] = "e-ee" elif c["id"] == "fff": c["id"] = "f_ff" elif c["id"] == "ggg": c["id"] = "g.gg" for i in range(len(baseProps["data"])): d = baseProps["data"][i] d["b+bb"] = d["bbb"] d["c cc"] = d["ccc"] d["d:dd"] = d["ddd"] d["e-ee"] = d["eee"] d["f_ff"] = d["fff"] d["g.gg"] = d["ggg"] baseProps.update(dict(filter_action="native")) baseProps.update(props) if clear: app.layout = Div([ DataTable(**baseProps), Button(id="btn", children=["Clear filters"]) ]) @app.callback(Output("table", "filter_query"), Input("btn", "n_clicks")) def get_filter(n_clicks): return "" else: app.layout = DataTable(**baseProps) return app
def get_app(props=dict()): app = dash.Dash(__name__) baseProps = get_props() for c in baseProps.get("columns"): c["clearable"] = True c["deletable"] = True c["hideable"] = "last" c["selectable"] = True baseProps["column_selectable"] = "multi" baseProps["filter_action"] = "native" baseProps["merge_duplicate_headers"] = True baseProps.update(props) app.layout = DataTable(**baseProps) return app
def get_app(props=dict()): app = dash.Dash(__name__) baseProps = get_props() for c in baseProps.get("columns"): c["clearable"] = True c["deletable"] = True c["hideable"] = "last" c["selectable"] = True baseProps["column_selectable"] = "multi" baseProps["filter_action"] = "native" baseProps["merge_duplicate_headers"] = True # first col is normally only 60px, make it wider since we're adding # all these actions and need to interact with them baseProps["style_cell_conditional"][0].update(width=120, maxWidth=120, minWidth=120) baseProps.update(props) app.layout = DataTable(**baseProps) return app