Skip to content

Add show_rows parameter to create_dt() function for customizable default row display#246

Merged
martinctc merged 5 commits into
mainfrom
copilot/fix-245
Aug 7, 2025
Merged

Add show_rows parameter to create_dt() function for customizable default row display#246
martinctc merged 5 commits into
mainfrom
copilot/fix-245

Conversation

Copilot AI commented Aug 4, 2025

Copy link
Copy Markdown
Contributor

This PR adds a new show_rows parameter to the create_dt() function to allow users to customize the default number of rows displayed in DataTable outputs, addressing a common user request for more flexible table display options.

The rounding argument also now accepts a named list, allowing more flexibility in specifying which rounding formats to use for which columns. This was achieved with backward compatibility.

Changes Made

New Parameter:

  • Added show_rows parameter with default value 10 to maintain backward compatibility
  • Accepts numeric values or "All" to specify the default number of rows to display
  • The specified value becomes the first option in the DataTable length menu

Dynamic Length Menu Construction:

  • Replaced hardcoded lengthMenu with dynamic construction based on show_rows value
  • When show_rows = 25: Creates menu [25, 10, 50, -1] with labels [25, 10, 50, "All"]
  • When show_rows = "All": Creates menu [-1, 25, 10, 50] with labels ["All", 25, 10, 50]
  • Other numeric values are placed first in the menu with remaining standard options

Examples:

# Default behavior (unchanged)
create_dt(data)

# Show 25 rows by default
create_dt(data, show_rows = 25)

# Show all rows by default
create_dt(data, show_rows = "All")

Backward Compatibility

All existing code continues to work without modification since show_rows defaults to 10, preserving the original behavior. The change affects 11 files across the codebase that use create_dt(), all of which remain fully compatible.

Testing

Added comprehensive test suite in test-create_dt.R to verify:

  • Default parameter behavior
  • Numeric show_rows values
  • "All" and -1 parameter values
  • Proper DataTable object creation

Fixes #245.

Co-authored-by: martinctc <17925865+martinctc@users.noreply.github.com>
Copilot AI changed the title [WIP] Feature request: create_dt() parameter to show default number of rows to show Add show_rows parameter to create_dt() function for customizable default row display Aug 4, 2025
Copilot AI requested a review from martinctc August 4, 2025 09:54
@martinctc martinctc marked this pull request as ready for review August 7, 2025 14:52
@martinctc martinctc merged commit 13cdba8 into main Aug 7, 2025
3 checks passed
@martinctc martinctc deleted the copilot/fix-245 branch August 7, 2025 14:53
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.

Feature request: create_dt() parameter to show default number of rows to show

2 participants