Refactoring header style code in TableView
kinderp opened this issue · comments
Antonio commented
Same or similar code is present in table_view.TableView
create a function to avoid repetitions.
render_header()
class_name = getattr(self.model, elem).__class__.__name__
if elem in self.style_header and class_name == 'TextField':
# atm header style con be applied only to TextField
# type. ( and class_name == 'TextField )
style_name = self.style_header[elem]['style']
commands = self.style_header[elem]['commands']
my_style = Styles.style(style=style_name,
commands=commands)
new_row.append(getattr(self.model,
elem).render(style=my_style))
else:
new_row.append(getattr(self.model, elem).render())
render_inner_table()
class_name = getattr(self.model, elem).__class__.__name__
if elem in self.style_header and class_name == 'TextField':
# atm header style con be applied only to TextField
# type. ( and class_name == 'TextField )
style_name = self.style_header[elem]['style']
commands = self.style_header[elem]['commands']
my_style = Styles.style(style=style_name,
commands=commands)
compliant_data[sr][sc] = getattr(self.model, elem).render(style=my_style)
else:
compliant_data[sr][sc] = getattr(self.model, elem).render()