Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for header_value for export header #970

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

5tefan
Copy link

@5tefan 5tefan commented Oct 21, 2024

Summary

A potential solve for #947.

Adds a header_value property on Column and BoundColumn, analogous to the current header property. Then, adjusts as_values to use the header_value property for export column headers. The header_value property returns header for backwards compatibility, but provides a way to customize export headers independently of headers in the html table view. This is important because header may include custom HTML that shouldn't be included in export formats.

Copy link
Owner

@jieter jieter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I have added some suggestions.

Comment on lines +582 to +585
column_header_value = self.column.header_value
if column_header_value:
return column_header_value
return self.header
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can safely write this as:

Suggested change
column_header_value = self.column.header_value
if column_header_value:
return column_header_value
return self.header
return column_header_value or self.header


When subclassing a column, the header in the html table can be customized by
overriding :meth:`~Column.header`. The header value for exports can be independently
customized using :meth:`~Column.render_value`.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
customized using :meth:`~Column.render_value`.
customized using :meth:`~Column.render_value`.

@@ -80,6 +80,10 @@ By default, it just calls the `render()` method on that column.
If your custom column produces HTML, you should override this method and return
the actual value.

For column headers, similarly sometimes :ref:Column.header`-may include html which
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For column headers, similarly sometimes :ref:Column.header`-may include html which
For column headers, similarly sometimes :ref:Column.header`-may include HTML which


By default this returns `~.Column.header`.

:returns: `unicode` or `None`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't unicode a python 2 construct?

Suggested change
:returns: `unicode` or `None`
:returns: `str` or `None`

@mschoettle
Copy link
Contributor

If this is used for exporting, would it make sense to have “export” in the argument name?

@jieter
Copy link
Owner

jieter commented Dec 23, 2024

If this is used for exporting, would it make sense to have “export” in the argument name?

Yes, I think export_header is a better name, export_value instead of value would have been a better choice too, but it's too established to change it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants