PaginatedTable API Reference
Complete reference for the PaginatedTable type for handling large datasets.
PaginatedTable Type
type PaginatedTable struct {
*Table // Embeds Table, inheriting its methods
// Internal pagination fields
}PaginatedTable extends Table with pagination and search capabilities. Perfect for datasets with 100+ rows.
Constructor Functions
NewPaginated()
Creates a new paginated table.
func NewPaginated(title string, pageSize int) *PaginatedTableParameters:
title(string): The window titlepageSize(int): Number of rows per page (must be > 0)
Returns:
*PaginatedTable: A new paginated table instance
Example:
table := gotableview.NewPaginated("Large Dataset", 50)
table.Columns("Name", "Email").Rows(largeDataset).Show()Recommended Page Sizes:
- Small (100-500 rows): 50
- Medium (500-5000 rows): 50-100
- Large (5000+ rows): 100-200
Configuration Methods
PaginatedTable inherits all methods from Table:
Columns()/ColumnNames()ColumnWidths()HeaderFont()ContentFont()
Columns()
Sets column headers (inherited from Table).
func (pt *PaginatedTable) Columns(cols ...string) *PaginatedTableReturns:
*PaginatedTable(for chaining)
Example:
table.Columns("ID", "Name", "Email", "Status")ColumnNames()
Alias for Columns().
func (pt *PaginatedTable) ColumnNames(names ...string) *PaginatedTableData Methods
Row()
Adds a single row (inherited but overridden).
func (pt *PaginatedTable) Row(values ...string) *PaginatedTableParameters:
values(...string): Cell values
Returns:
*PaginatedTable
Example:
table.Row("1", "Alice", "alice@example.com", "Active")Rows()
Adds multiple rows at once.
func (pt *PaginatedTable) Rows(data [][]string) *PaginatedTableParameters:
data([][]string): 2D slice of row data
Returns:
*PaginatedTable
Example:
data := loadLargeDataset() // 1000 rows
table.Rows(data)Search Features
WithSearch()
Enables search functionality across all columns.
func (pt *PaginatedTable) WithSearch() *PaginatedTableReturns:
*PaginatedTable
Features:
- Adds search box above table
- Real-time filtering as you type
- Case-insensitive search
- Searches all columns
- Updates pagination automatically
Example:
gotableview.NewPaginated("Employees", 50).
Columns("Name", "Department", "Email").
Rows(employees).
WithSearch(). // Search all 3 columns
Show()SearchInColumns()
Enables search on specific columns by name.
func (pt *PaginatedTable) SearchInColumns(columnNames ...string) *PaginatedTableParameters:
columnNames(...string): Names of columns to search
Returns:
*PaginatedTable
Important:
- Column names must exactly match (case-sensitive)
- Invalid column names are ignored
- More efficient than searching all columns
Example:
gotableview.NewPaginated("Products", 50).
Columns("ID", "Name", "Category", "Price", "Description").
Rows(products).
SearchInColumns("Name", "Category"). // Search only these 2
Show()SearchInColumnIndices()
Enables search on specific columns by index.
func (pt *PaginatedTable) SearchInColumnIndices(indices ...int) *PaginatedTableParameters:
indices(...int): Zero-based column indices
Returns:
*PaginatedTable
Important:
- Indices are zero-based (first column = 0)
- Invalid indices are ignored
Example:
gotableview.NewPaginated("Data", 50).
Columns("Col0", "Col1", "Col2", "Col3").
Rows(data).
SearchInColumnIndices(1, 3). // Search columns 1 and 3
Show()WithColumnSelector()
Adds a dropdown for users to choose which column to search.
func (pt *PaginatedTable) WithColumnSelector() *PaginatedTableReturns:
*PaginatedTable
Features:
- Dropdown appears next to search box
- "All Columns" option (default)
- Individual column options
- Search updates when selection changes
Example:
gotableview.NewPaginated("Products", 50).
Columns("ID", "Name", "Category", "Price").
Rows(products).
WithColumnSelector(). // User chooses column
Show()Font Methods
HeaderFont()
Sets header font (inherited from Table).
func (pt *PaginatedTable) HeaderFont(name string, size int, bold, italic bool) *PaginatedTableReturns:
*PaginatedTable
ContentFont()
Sets content font (inherited from Table).
func (pt *PaginatedTable) ContentFont(name string, size int, bold, italic bool) *PaginatedTableReturns:
*PaginatedTable
Display Method
Show()
Displays the paginated table window.
func (pt *PaginatedTable) Show()Features Added to Basic Table:
- "< Previous" button
- "Next >" button
- Page indicator: "Page X of Y (Showing A-B of C rows)"
- Search box (if enabled)
- Column selector dropdown (if enabled)
Example:
table.Show() // Blocks until window closedPagination Controls
When you call Show(), these controls appear automatically:
Navigation Buttons
< Previous: Go to previous page
- Disabled on first page
- Keyboard shortcut: Left arrow (future)
Next >: Go to next page
- Disabled on last page
- Keyboard shortcut: Right arrow (future)
Page Indicator
Shows current position:
Page 3 of 15 (Showing 201-300 of 1500 rows)- Current page number
- Total pages
- Row range on current page
- Total rows (after filtering)
Complete Examples
Example 1: Basic Pagination
package main
import "github.com/mansoldof/goTableView"
func main() {
// Load 500 rows
data := loadData()
gotableview.NewPaginated("Data", 50).
Columns("ID", "Name", "Value").
Rows(data).
Show()
}Example 2: Pagination + Search All
gotableview.NewPaginated("Employees", 100).
Columns("Name", "Department", "Email", "Phone").
Rows(employees).
WithSearch(). // Search all columns
Show()Example 3: Pagination + Column Search
gotableview.NewPaginated("Products", 50).
Columns("ID", "Name", "Category", "Price", "Stock").
Rows(products).
SearchInColumns("Name", "Category"). // Search specific columns
Show()Example 4: Pagination + Column Selector
gotableview.NewPaginated("Logs", 100).
Columns("Time", "Level", "Source", "Message").
Rows(logs).
WithColumnSelector(). // User chooses column
Show()Example 5: All Features
gotableview.NewPaginated("Full Featured", 50).
Columns("ID", "Name", "Category", "Price", "Stock").
ColumnWidths(60, 200, 120, 100, 80).
HeaderFont("Arial", 11, true, false).
ContentFont("Segoe UI", 10, false, false).
Rows(largeDataset).
WithColumnSelector().
Show()Search Behavior
Case Insensitivity
All searches are case-insensitive:
// Searching "engineering" will match:
// "Engineering", "ENGINEERING", "engineering", "EnGiNeErInG"Partial Matching
Search matches any part of the cell:
// Searching "john" will match:
// "John Smith", "johnson@example.com", "Johnny", "john123"Real-Time Filtering
- Results update as you type
- No need to press Enter
- Pagination updates automatically
- Row count updates immediately
Performance Tips
Choose Appropriate Page Size
// Too small - excessive clicking ❌
gotableview.NewPaginated("Data", 10).Rows(bigData).Show()
// Too large - slow rendering ❌
gotableview.NewPaginated("Data", 1000).Rows(bigData).Show()
// Just right ✅
gotableview.NewPaginated("Data", 100).Rows(bigData).Show()Limit Search Columns
// Slower - searches 8 columns
WithSearch()
// Faster - searches 2 columns
SearchInColumns("Name", "Email")Use Column Selector for Flexibility
// Best of both worlds:
// - Fast search (one column at a time)
// - User can search any column they want
WithColumnSelector()Comparison with Table
| Feature | Table | PaginatedTable |
|---|---|---|
| Max Recommended Rows | ~100 | 100,000+ |
| Pagination | ❌ | ✅ |
| Search | ❌ | ✅ |
| Column Selector | ❌ | ✅ |
| Memory Usage | Higher (all visible) | Lower (page at a time) |
| Rendering Speed | Slower for large data | Consistent |
| Use Case | Small datasets | Large datasets |
See Also
- Table API - Basic table reference
- Helper Functions -
FromStructsPaginated(), etc. - Pagination Guide
- Advanced Examples