Skip to content

Conversation

@RubenMartins
Copy link
Contributor

@RubenMartins RubenMartins commented Jul 15, 2019

Added support to sort columns automatically by the type of field text, number, date or time.

Description

Added support to sort columns automatically in admin tables list when the "column" attribute is true.
This will sort by field type (text, number, date or time) using (query "orderby" -> meta_value, meta_value_num, meta_value_time or meta_value_date accordingly).

Motivation and Context

There was a need to sort columns generated by CMB2 automatically without custom code.
Fixes #831.

Risk Level

minimal risk

Testing procedure

Using the example-functions.php you can verify that the field with column attribute defined will automatically be able to sort.

Types of changes

New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • My code and pull requests meets the Contributing guidelines.
  • If this will be merged please verify the "[at]since" tag on the new functions created

Added support to sort columns automatically by the type of field text, number, date or time.
@jtsternberg
Copy link
Member

This is pretty cool. There's definitely some Code Standards cleanup required. Can you please address that?

@RubenMartins RubenMartins deleted the patch-5 branch July 15, 2019 20:05
@RubenMartins RubenMartins restored the patch-5 branch July 15, 2019 20:05
@RubenMartins RubenMartins reopened this Jul 15, 2019
@RubenMartins
Copy link
Contributor Author

Clicked the wrong button and closed this unintentionally, sorry for the notifications.

@jtsternberg Can you please review the cleanup? If you found any further necessary cleanup can you please point it out?

Copy link
Member

@jtsternberg jtsternberg left a comment

Choose a reason for hiding this comment

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

Thanks for your submission. I added a few suggestions.

@RubenMartins
Copy link
Contributor Author

Thanks for your submission. I added a few suggestions.

Fixed @jtsternberg, thank you for your help

@jtsternberg jtsternberg merged commit 2f99316 into CMB2:develop Jul 16, 2019
jtsternberg added a commit that referenced this pull request Jul 16, 2019
@jtsternberg
Copy link
Member

Nice work on this @RubenMartins! Thank you for submitting and following up with the cleanup.

@RubenMartins RubenMartins deleted the patch-5 branch July 16, 2019 19:24
@RubenMartins
Copy link
Contributor Author

@jtsternberg Can this be added to the 2.7.0 milestone?
Do you have an ETA on making this available with the WordPress plugin?

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.

Sorting column Field Parameter

2 participants