You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'm really loving the support in itables for both pandas and polars!
While looking through the code for itables, I noticed it's able to use the .to_html() method of DataFrames, so should also be able to display a Great Tables GT object.
However, I wasn't quite able to get it to work. I could produce the necessary HTML, but ran into a javascript error. Any chance you might be interested in adding Great Tables support? We'd love to be able to provide an interactive table with pagination! I'm happy to dig more, but wanted to check here in case you have a better sense of how Great Tables could be plugged in.
Here's the javascript error, and the code I used to produce it.
Error:
"Cannot read properties of undefined (reading 'mData')".
Python code
fromitables.javascriptimportset_default_options, to_html_datatable_using_to_htmlfromgreat_tablesimportexibble, GTfromIPython.displayimportHTML, Javascript, display# Modify GT class to work with what itables expects ---------# this section adds .to_html() and .__len__ methods to GTdefto_html(self: GT, table_id: str, classes:str="") ->str:
rendered=self.render("html")
# rough hack to insert id and classes itables expectsreturn (
rendered
.replace("<table ", f'<table id="{table_id}" ')
.replace('class="gt_table" ', f'class="gt_table {classes}" ')
)
GT.to_html=to_htmlGT.__len__=lambdaself: len(self._tbl_data)
# define a GT table ----------#gt=GT(exibble).tab_spanner("SPANNER", ["date", "time"])
gt# attempt to display using itables -----------#opts= {"css": "", "id": "T_abcd", "pre_dt_code": ""}
set_default_options(opts, use_to_html=True)
display(HTML(to_html_datatable_using_to_html(gt, tableId="T_abcd")))
The text was updated successfully, but these errors were encountered:
Hey @machow , thanks for reaching out! Yes certainly I would love to add support for Great Tables. Recently we added support for Pandas Style objects so I imagine we should be able to do GT as well.
Thanks for the example above, I will have a look when time permits.
Hello, I'm really loving the support in itables for both pandas and polars!
While looking through the code for itables, I noticed it's able to use the
.to_html()
method of DataFrames, so should also be able to display a Great Tables GT object.However, I wasn't quite able to get it to work. I could produce the necessary HTML, but ran into a javascript error. Any chance you might be interested in adding Great Tables support? We'd love to be able to provide an interactive table with pagination! I'm happy to dig more, but wanted to check here in case you have a better sense of how Great Tables could be plugged in.
Here's the javascript error, and the code I used to produce it.
Error:
Python code
The text was updated successfully, but these errors were encountered: