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

Feature Request: Ability to filter on arbitrary data #174

Open
trevorstarick opened this issue May 15, 2024 · 8 comments
Open

Feature Request: Ability to filter on arbitrary data #174

trevorstarick opened this issue May 15, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@trevorstarick
Copy link

Hi,

I'm looking at implementing some functionality for filtering on arbitrary data. Right now I'm looking at the ability to filter on stuff like "is the docker container in the table online, what is it's state, etc..." but without having that data visible to the end user.

My first idea was somehow hiding the column completely, but couldn't find the ability to do that; so my next idea was implementing a system to filter on metadata passed in the row (the extra stuff that doesn't end up in a column) but I didn't think that that was possible either.

So I'm planning on adding the functionality via a PR but wanted to open up a discussion first before going off and implementing the feature. My plan is to add a WithHidden(bool) method to the table.Column which will just handle it's inclusion in width calculation (consider the width to be zero) and cause it not to be rendered.

@trevorstarick
Copy link
Author

Alternatively, being able to filter on arbitrary data or pass in a FilterFunc(map[string]interface{}) bool would probably solve my issue.

@trevorstarick
Copy link
Author

#175

@Evertras
Copy link
Owner

Hey there, sorry for the delay in response.

I'm a little nervous about adding a 'hidden' field to the column because there's already an idea of just not including the column if you want it to be hidden, and then this adds some overhead to the table itself now. It's a small amount of overhead, but still.

I do like the idea of the filterfunc which gets passed each row individually to allow more fine grained control of filtering. I would expect the filterfunc to be applicable to the table as a whole, and if it exists, then each row is checked on the filterfunc rather than the current standard behavior. It seems potentially useful if we can attach it to the columns as well, but I think the real benefit would be if we attach it to the table as a whole. It should then also have a way to restore standard filtering, maybe just passing nil as the filterfunc being documented as a way to do that is enough.

@Evertras Evertras added the enhancement New feature or request label May 17, 2024
@trevorstarick
Copy link
Author

I've added the hidden column functionality to the PR I made, but I can work around that feature if I add the TableRow.FilterFunc instead of just the TableData[].FilterFunc + TableColumn.Hidden features.

I'll mess around with that later today

@Evertras
Copy link
Owner

Just to make sure we're on the same page, I think your idea of FilterFunc(map[string]interface{}) bool is probably going to be the way to go for flexibility here.

@trevorstarick
Copy link
Author

trevorstarick commented May 18, 2024

Yup, I'm gonna remove the .Hidden in my existing PR

@Evertras
Copy link
Owner

Hi @trevorstarick just checking if you were able to take another look at this?

@trevorstarick
Copy link
Author

I've updated my PR. I'm still missing tests with the filterFunc but the functionality is there

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

No branches or pull requests

2 participants