Skip to content

TableView is a custom class that implements a table view to display data as a table

License

Notifications You must be signed in to change notification settings

4d49/table-view

Repository files navigation

TableView

TableView is a custom class that implements a table view to display data as a table. It is similar to the built-in Tree class.

Important

Only Godot 4.4+ is supported. This add-on is still in development and needs testing!

Features

  • Column sorting capabilities
  • Filter rows with a custom Callable method
  • In-place cell value editing

Installation

  1. git clone this repository to addons folder.
  2. Enable Table View in Plugins.
  3. Done!

Usage

A TableView does not provide a built-in user interface for managing columns and rows. Instead, all control and customization must be done programmatically through code.

Getting Started

First, I recommend checking out the test scene in the repository.

Prepare

Add TableView as a child node to the scene.

# Declare a `TableView` in a parent node.
@onready var table_view: TableView = $TableView

Create columns

# The `add_column` method returns the index of the newly created column.
# The first argument defines the column title, and the second defines its data type.
var name = table_view.add_column("Name", TableView.Type.STRING)
var unique = table_view.add_column("Unique", TableView.Type.BOOL)
# The third argument defines the hint type.
var cost = table_view.add_column("Cost", TableView.Type.INT, TableView.Hint.hint_range(0, 1000))

Creating rows

for item: Dictionary in get_items(): # Returns an array of dictionaries.
	# Adds a new row and returns the index of the newly created row.
	var row = table_view.add_row()

	# Previously declared variables are passed as the column index argument.
	table_view.set_cell_value(row, name, item.name)
	table_view.set_cell_value(row, unique, item.unique)
	table_view.set_cell_value(row, cost, item.cost)

FAQ

Why would you implement a custom class when a Tree node can do almost all the same things?

Because I can.

License

Copyright (c) 2024-2025 Mansur Isaev and contributors

Unless otherwise specified, files in this repository are licensed under the MIT license. See LICENSE.md for more information.

About

TableView is a custom class that implements a table view to display data as a table

Topics

Resources

License

Stars

Watchers

Forks