Set initial value for header_filter in Tabulator

Is there a way to set the initial value for header_filter?

Here are the options I tried:

import numpy as np
import panel as pn
pn.extension("tabulator")
df = pd.DataFrame(np.random.rand(100,3)-.5, columns=list("xyz"))

hf = {"x":
      {'type': 'number', 'func': '>=', 'value':0}, # most intuitive to me
#       {'type': 'number', 'func': '>=', 'default':0},
#       {'type': 'number', 'func': '>=', 'on_start':0},
#       {'type': 'number', 'func': '>=', 'initial':0},
#       {'type': 'number', 'func': '>=', 'initialValue':0},
#       {'type': 'number', 'func': '>=', 'load':0},
#       {'type': 'number', 'func': '>=', 'onload':0},
     }
tbl = pn.widgets.Tabulator(df, header_filters=hf, height=300)
tbl

There are a lot of additional Tabulator options. Go to the Static Configuration in the docs.

This should solve your issue:

import numpy as np
import pandas as pd
import panel as pn
pn.extension("tabulator")
df = pd.DataFrame(np.random.rand(100,3)-.5, columns=list("xyz"))

hf = {"x":{'type': 'number', 'func': '>='}}

initial_filter = [{'field':'x','value':0}]

tbl = pn.widgets.Tabulator(df, header_filters=hf, configuration = {'initialHeaderFilter':initial_filter}, height=300, width = 900)
tbl
1 Like

wow, thanks a lot @riziles. I don’t think I would have arrived there on my own.

No problem! I love Tabulator + Panel. Now if I could only get the “tree” view to work…

1 Like

Hi @riziles

  • How exactly you would like to use the Tabulator Treeview?
  • Have you tried filing a feature request?
  • Have you tried building some custom solution using ReactiveHTML?

@Marc ,

  • I actually think Treeview used to work at some point using the Hierarchical Multi-Index Function. I’m pretty sure I had it working but then lost it in one of the package updates. I also don’t think the example on the doc site is functioning correctly.
  • No, because I can approximate the functionality with Perspective or a custom widget. I mostly use Panel for fun, so it didn’t seem worth bugging a developer over it.
  • Yes. See example here: Tabulator DataTree - #3 by riziles

Thanks,
Riz