Conditionally determine visibility of columns in datatables #2044
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows us to conditionally show / hide columns in a datatable.
It works by defining an
optional_condition
callable on aColumn
definition for datatables. Theoptional_condition
will be called with the object for that row as parameter for each visible row on the page. If non of the calls evaluate toTrue
, the column will be hidden. The visibility is recalculated each time the table data changes: pagination changes, search changes, ordering changes, etc.This will be useful when the fields in DIAGNijmegen/rse-panimg#51 are implemented here and we want to show these columns in the archive cases list view, but hide the columns that contain empty values.
As an example I made the "Algorithm Results" column in the cases list view only visible if it actually contains algorithm results.