Added lazy loading when showing grid to improve performance
This commit is contained in:
@@ -642,10 +642,10 @@ def extract_table_values_new(ft, header=True):
|
||||
# first, get the header
|
||||
|
||||
if header:
|
||||
header = search_elements_by_name(ft, attrs={"class": "dt2-header"}, comparison_method='contains')[0]
|
||||
header_element = search_elements_by_name(ft, attrs={"class": "dt2-header"}, comparison_method='contains')[0]
|
||||
header_map = {}
|
||||
res = OrderedDict()
|
||||
for row in header.children:
|
||||
for row in header_element.children:
|
||||
col_id = row.attrs["data-col"]
|
||||
title = row.attrs["data-tooltip"]
|
||||
header_map[col_id] = title
|
||||
@@ -654,9 +654,10 @@ def extract_table_values_new(ft, header=True):
|
||||
body = search_elements_by_name(ft, attrs={"class": "dt2-body"}, comparison_method='contains')[0]
|
||||
for row in body.children:
|
||||
for col in row.children:
|
||||
col_id = col.attrs["data-col"]
|
||||
cell_value = _get_cell_content_value(col)
|
||||
res[header_map[col_id]].append(cell_value)
|
||||
if hasattr(col, "attrs"):
|
||||
col_id = col.attrs["data-col"]
|
||||
cell_value = _get_cell_content_value(col)
|
||||
res[header_map[col_id]].append(cell_value)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
@@ -509,3 +509,18 @@ def test_i_can_compute_footer_menu_position_when_not_enough_space(dg):
|
||||
)
|
||||
|
||||
assert matches(menu, expected)
|
||||
|
||||
|
||||
def test_the_content_of_the_cell_is_escaped(empty_dg):
|
||||
df = pd.DataFrame({
|
||||
'value': ['<div> My Content </div>'],
|
||||
'value2': ['{My Content}'],
|
||||
})
|
||||
my_dg = empty_dg.init_from_dataframe(df)
|
||||
|
||||
actual = my_dg.__ft__()
|
||||
table_content = extract_table_values_new(actual, header=True)
|
||||
|
||||
assert table_content == OrderedDict({
|
||||
'value': ['<div> My Content </div>'],
|
||||
'value2': ['{My Content}']})
|
||||
|
||||
Reference in New Issue
Block a user