{"id":28709696,"url":"https://github.com/stefanuebe/vaadin-html-table","last_synced_at":"2025-06-14T20:18:27.957Z","repository":{"id":44920845,"uuid":"360487456","full_name":"stefanuebe/vaadin-html-table","owner":"stefanuebe","description":"HTML Table integration for Flow","archived":false,"fork":false,"pushed_at":"2023-05-25T12:47:17.000Z","size":296,"stargazers_count":4,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-14T20:18:26.518Z","etag":null,"topics":["html-element","java","table","vaadin","vaadin-addon","vaadin-flow"],"latest_commit_sha":null,"homepage":"https://vaadin.com/directory/component/html-table","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stefanuebe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-22T10:59:04.000Z","updated_at":"2024-01-20T05:26:44.000Z","dependencies_parsed_at":"2022-09-15T19:02:15.158Z","dependency_job_id":null,"html_url":"https://github.com/stefanuebe/vaadin-html-table","commit_stats":null,"previous_names":["stefanuebe/vaadin-html-table"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/stefanuebe/vaadin-html-table","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanuebe%2Fvaadin-html-table","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanuebe%2Fvaadin-html-table/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanuebe%2Fvaadin-html-table/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanuebe%2Fvaadin-html-table/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefanuebe","download_url":"https://codeload.github.com/stefanuebe/vaadin-html-table/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanuebe%2Fvaadin-html-table/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259877576,"owners_count":22925408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html-element","java","table","vaadin","vaadin-addon","vaadin-flow"],"created_at":"2025-06-14T20:18:19.634Z","updated_at":"2025-06-14T20:18:27.943Z","avatar_url":"https://github.com/stefanuebe.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HTML Table\n\nVaadin Flow integration of the html Table elements.\n\n## Description\n\nThis addon provides a low-level api to work with a html table and related \nelements. It allows you to create a simple table consisting of rows and cells\nor to use a more structured approach by defining columns, a head, body and foot.\n\n## Features\n* support of adding table rows, header and data cells as direct children, or\n* structuring the table by using tbody, thead and tfoot\n* takes care of the correct order of sub elements of the table (e.g. thead before tbody, etc.)\n* rows added to the table are automatically transferred to the tbody, when created\n* support for a table caption element\n* support for column groups and columns\n* table cells can define their col- and rowspan\n* table header cells can get a scope assigned\n* convenient api for easy adding or removing sub elements\n\n## Dedicated Testbench elements\nIf you want to create Testbench tests testing table elements, you can reuse this\npredefined set of elements: https://vaadin.com/directory/component/html-table-testbench-elements.\n\n# Exapmles\n## Creating a simple table\n```\nTable table = new Table();\n\nTableRow headerRow = table.addRow();\nheaderRow.addHeaderCell().setText(\"Hello\");\nheaderRow.addHeaderCell().setText(\"World\");\n\nTableRow detailsRow = table.addRow();\ndetailsRow.addDataCell().setText(\"Hello\");\ndetailsRow.addDataCell().setText(\"World\");\n```\n\n## Applying colspan and rowspan to cells\n```\nTable table = new Table();\n\nTableRow headerRow = table.addRow();\nTableCell cell = headerRow.addHeaderCell();\ncell.setText(\"Hello world, it's me.\");\ncell.setColSpan(3);\ncell.getStyle().set(\"background-color\", \"#fdd\");\n\nTableRow detailsRow = table.addRow();\ndetailsRow.addDataCell().setText(\"Hello\");\ndetailsRow.addDataCell().setText(\"World\");\n\ncell = detailsRow.addDataCell();\ncell.setText(\"It's me.\");\ncell.setRowSpan(2);\ncell.getStyle().set(\"background-color\", \"#dfd\");\n\ndetailsRow = table.addRow();\ncell = detailsRow.addDataCell();\ncell.setText(\"Hello\");\ncell.setColSpan(2);\ncell.getStyle().set(\"background-color\", \"#ddf\");\n\ntable.getCaption().setText(\"Using col- and rowspan\");\n\nadd(table);\n```\n\n## Using a caption element\n```\nTable table = new Table();\n\ntable.getCaption().setText(\"Some caption\"); \n\n// caption also supports components\ntable.getCaption().add(new Image(...));\n```\n\n## Structuring the table\n```\n// Table takes care to order the elements on the client side as required by html specifications\n\nTable table = new Table();\n\nTableRow detailsRow = table.getBody().addRow();\ndetailsRow.addDataCell().setText(\"Hello\");\ndetailsRow.addDataCell().setText(\"World\");\nadd(table);\n\nTableHead head = table.getHead(); // will be put before tbody in the client side dom\nTableRow headerRow = head.addRow();\nheaderRow.addHeaderCell().setText(\"Hello\");\nheaderRow.addHeaderCell().setText(\"World\");\n\ntable.getCaption().setText(\"Using thead and tbody\"); // will be put before thead in the client side dom\n\nadd(table);\n```\n\n## Using column groups\n```\nTable table = new Table();\n\nTableHead head = table.getHead();\nTableRow headerRow = head.addRow();\nheaderRow.addHeaderCell().setText(\"Hello with Style\");\nheaderRow.addHeaderCell().setText(\"World with Style\");\nheaderRow.addHeaderCell().setText(\"Hello\");\nheaderRow.addHeaderCell().setText(\"World\");\n\nTableRow detailsRow = table.getBody().addRow();\ndetailsRow.addDataCell().setText(\"Hello with Style\");\ndetailsRow.addDataCell().setText(\"World with Style\");\ndetailsRow.addDataCell().setText(\"Hello\");\ndetailsRow.addDataCell().setText(\"World\");\n\nTableColumnGroup columnGroup = table.getColumnGroup();\nTableColumn column = columnGroup.addColumn();\ncolumn.addClassName(\"some\");\ncolumn.setSpan(2);\n\nheaderRow.streamHeaderCells().forEach(c -\u003e c.setScope(TableHeaderCell.SCOPE_COLUMN));\n\ntable.getCaption().setText(\"Using colgroups, thead and tbody\");\n\nadd(table);\n```\n\n## Integrating Vaadin components\n```\nTable table = new Table();\n\nTableRow headerRow = table.addRow();\nheaderRow.addHeaderCell().setText(\"Name\");\nheaderRow.addHeaderCell().setText(\"Age\");\n\nfor (int i = 0; i \u003c 10; i++) {\n    TextField textField = new TextField();\n    textField.setValue(\"Some user \" + i );\n\n    NumberField numberField = new NumberField();\n    numberField.setValue((double) (20 + i));\n\n    TableRow detailsRow = table.addRow();\n    detailsRow.addDataCell().add(textField);\n    detailsRow.addDataCell().add(numberField);\n}\n\nadd(table);\n```\n\n## Changing the content\n```\n// The table and its content is modifiable as any other Vaadin component\n\nTable table = new Table();\ntable.setWidth(\"500px\");\n\nTableRow headerRow = table.addRow();\nheaderRow.addHeaderCell().setText(\"Hello\");\nheaderRow.addHeaderCell().setText(\"World\");\n\nTableRow detailsRow = table.addRow();\ndetailsRow.addDataCell().setText(\"Hello\");\ndetailsRow.addDataCell().setText(\"World\");\n\nadd(table, new Button(\"Change cell content\", event -\u003e {\n    table.getRow(1)\n            .flatMap(row -\u003e row.getCell(1))\n            .ifPresent(cell -\u003e cell.setText(\"You :)\"));\n}));\n```\n\n## Creating a Testbench testcase\n```\n// Needs the html-table-testbench-elements\n// @see https://vaadin.com/directory/component/html-table-testbench-elements\n\npublic class SimpleTableViewIT extends TestBenchTestCase {\n\n    // ... test setup and init\n\n    @Test\n    public void componentWorks() {\n        TableElement table = getTable();\n\n        Assert.assertFalse(\"caption\" + \" must not be present\", table.getOptionalCaption().isPresent());\n        Assert.assertFalse(\"colgroup\" + \" must not be present\", table.getOptionalColumn().isPresent());\n        Assert.assertFalse(\"thead\" + \" must not be present\", table.getOptionalHead().isPresent());\n        Assert.assertFalse(\"tbody\" + \" must not be present\", table.getOptionalBody().isPresent());\n        Assert.assertFalse(\"tfoot\" + \" must not be present\", table.getOptionalFoot().isPresent());\n\n        List\u003cTableRowElement\u003e rows = table.getRows();\n        Assert.assertEquals(2, rows.size());\n\n        TableRowElement row = rows.get(0);\n        List\u003cTableHeaderCellElement\u003e headerCells = row.getHeaderCells();\n        List\u003cTableDataCellElement\u003e dataCells = row.getDataCells();\n        Assert.assertEquals(2, headerCells.size());\n        Assert.assertEquals(0, dataCells.size());\n\n        Assert.assertEquals(\"Hello\", headerCells.get(0).getText());\n        Assert.assertEquals(\"World\", headerCells.get(1).getText());\n\n        row = rows.get(1);\n        headerCells = row.getHeaderCells();\n        dataCells = row.getDataCells();\n        Assert.assertEquals(0, headerCells.size());\n        Assert.assertEquals(2, dataCells.size());\n\n        Assert.assertEquals(\"Hello\", dataCells.get(0).getText());\n        Assert.assertEquals(\"World\", dataCells.get(1).getText());\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanuebe%2Fvaadin-html-table","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanuebe%2Fvaadin-html-table","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanuebe%2Fvaadin-html-table/lists"}