survos / simple-datatables-bundle
incorporate simple datatables, using twig and stimulus
Package info
github.com/survos/simple-datatables-bundle
Type:symfony-bundle
pkg:composer/survos/simple-datatables-bundle
Fund package maintenance!
Requires
- php: ^8.5
- survos/kit-bundle: ^2.5
- symfony/config: ^7.4||^8.1
- symfony/dependency-injection: ^7.4||^8.1
- symfony/http-kernel: ^7.4||^8.1
- symfony/options-resolver: ^7.4||^8.1
- symfony/stimulus-bundle: ^2.32 || ^3.0
- symfony/ux-twig-component: ^2.32 || ^3.0
- twig/twig: ^3.4|^4.0
Requires (Dev)
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^13.0
- rector/rector: ^2.0
- symfony/browser-kit: ^7.4||^8.1
- symfony/framework-bundle: ^7.4||^8.1
- symfony/phpunit-bridge: ^7.4||^8.1
- symfony/twig-bundle: ^7.4||^8.1
- symfony/var-dumper: ^7.4||^8.1
Suggests
- monolog/monolog: Allows more advanced logging of the application flow
Provides
None
Conflicts
None
Replaces
None
- 2.36.0
- 2.35.7
- 2.35.1
- 2.35.0
- 2.34.40
- 2.34.39
- 2.34.29
- 2.33.0
- 2.31.7
- 2.19.4
- 2.18.18
- 2.10.19
- 2.10.18
- 2.10.17
- 2.10.16
- 2.10.15
- 2.10.14
- 2.10.13
- 2.10.12
- 2.10.11
- 2.10.10
- 2.10.9
- 2.10.8
- 2.10.7
- 2.10.6
- 2.10.5
- 2.10.4
- 2.10.3
- 2.10.2
- 2.10.1
- 2.10.0
- 2.9.4
- 2.9.3
- 2.9.2
- 2.9.1
- 2.9.0
- 2.8.4
- 2.8.3
- 2.8.1
- 2.8.0
- 2.7.23
- 2.7.22
- 2.7.21
- 2.7.20
- 2.7.19
- 2.7.18
- 2.7.17
- 2.7.16
- 2.7.15
- 2.7.14
- 2.7.13
- 2.7.12
- 2.7.11
- 2.7.10
- 2.7.9
- 2.7.8
- 2.7.7
- 2.7.6
- 2.7.5
- 2.7.4
- 2.7.3
- 2.7.2
- 2.7.1
- 2.7.0
- 2.6.0
- 2.5.8
- 2.5.7
- 2.5.6
- 2.5.5
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.4
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.0
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.2
- 2.1.1
- 2.0.220
- 2.0.219
- 2.0.218
- 2.0.217
- 2.0.216
- 2.0.215
- 2.0.214
- 2.0.213
- 2.0.212
- 2.0.211
- 2.0.210
- 2.0.209
- 2.0.208
- 2.0.207
- 2.0.206
- 2.0.205
- 2.0.204
- 2.0.203
- 2.0.202
- 2.0.201
- 2.0.200
- 2.0.199
- 2.0.198
- 2.0.197
- 2.0.196
- 2.0.195
- 2.0.194
- 2.0.193
- 2.0.192
- 2.0.191
- 2.0.190
- 2.0.189
- 2.0.188
- 2.0.187
- 2.0.186
- 2.0.185
- 2.0.184
- 2.0.183
- 2.0.182
- 2.0.181
- 2.0.180
- 2.0.179
- 2.0.178
- 2.0.177
- 2.0.176
- 2.0.175
- 2.0.174
- 2.0.173
- 2.0.172
- 2.0.171
- 2.0.170
- 2.0.169
- 2.0.168
- 2.0.167
- 2.0.166
- 2.0.165
- 2.0.164
- 2.0.163
- 2.0.162
- 2.0.161
- 2.0.160
- 2.0.159
- 2.0.158
- 2.0.156
- 2.0.155
- 2.0.154
- 2.0.146
- 2.0.145
- 2.0.144
- 2.0.143
- 2.0.142
- 2.0.141
- 2.0.140
- 2.0.139
- 2.0.138
- 2.0.137
- 2.0.136
- 2.0.135
- 2.0.134
- 2.0.133
- 2.0.132
- 2.0.131
- 2.0.130
- 2.0.129
- 2.0.128
- 2.0.127
- 2.0.126
- 2.0.125
- 2.0.124
- 2.0.123
- 2.0.122
- 2.0.121
- 2.0.120
- 2.0.119
- 2.0.117
- 2.0.116
- 2.0.115
- 2.0.114
- 2.0.113
- 2.0.112
- 2.0.111
- 2.0.110
- 2.0.109
- 2.0.108
- 2.0.107
- 2.0.106
- 2.0.105
- 2.0.104
- 2.0.103
- 2.0.102
- 2.0.101
- 2.0.100
- 2.0.99
- 2.0.98
- 2.0.97
- 2.0.96
- 2.0.95
- 2.0.94
- 2.0.93
- 2.0.92
- 2.0.91
- 2.0.90
- 2.0.89
- 2.0.88
- 2.0.87
- 2.0.86
- 2.0.85
- 2.0.84
- 2.0.83
- 2.0.82
- 2.0.81
- 2.0.80
- 2.0.79
- 2.0.78
- 2.0.77
- 2.0.76
- 2.0.75
- 2.0.74
- 2.0.73
- 2.0.72
- 2.0.71
- 2.0.70
- 2.0.69
- 2.0.68
- 2.0.67
- 2.0.66
- 2.0.65
- 2.0.64
- 2.0.63
- 2.0.62
- 2.0.61
- 2.0.60
- 2.0.59
- 2.0.58
- 2.0.57
- 2.0.56
- 2.0.55
- 2.0.54
- 2.0.53
- 2.0.51
- 2.0.50
- 2.0.49
- 2.0.48
- 2.0.47
- 2.0.46
- 2.0.45
- 2.0.44
- 2.0.43
- 2.0.42
- 2.0.41
- 2.0.40
- 2.0.39
- 2.0.38
- 2.0.37
- 2.0.36
- 2.0.35
- 2.0.34
- 2.0.33
- 2.0.32
- 2.0.31
- 2.0.30
- 2.0.29
- 2.0.28
- 2.0.27
- 2.0.26
- 2.0.25
- 2.0.24
- 2.0.23
- 2.0.22
- 2.0.21
- 2.0.20
- 2.0.19
- 2.0.18
- 2.0.17
- 2.0.16
- 2.0.15
- dev-main / 1.6.x-dev
- 1.6.44
- 1.6.43
- 1.6.42
- 1.6.41
- 1.6.40
- 1.6.39
- 1.6.38
- 1.6.37
- 1.6.36
- 1.6.35
- 1.6.34
- 1.6.33
- 1.6.32
- 1.6.31
- 1.6.30
- 1.6.29
- 1.6.28
- 1.6.27
- 1.6.26
- 1.6.25
- 1.6.24
- 1.6.23
- 1.6.22
- 1.6.21
- 1.6.20
- 1.6.19
- 1.6.18
- 1.6.17
- 1.6.16
- 1.6.15
- 1.6.14
- 1.6.13
- 1.6.12
- 1.6.11
- 1.6.10
- 1.6.9
- 1.6.8
- 1.6.7
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.529
- 1.5.528
- 1.5.527
- 1.5.526
- 1.5.525
- 1.5.524
- 1.5.523
- 1.5.522
- 1.5.521
- 1.5.520
- 1.5.519
- 1.5.518
- 1.5.517
- 1.5.516
- 1.5.515
- 1.5.514
- 1.5.513
- 1.5.512
- 1.5.511
- 1.5.510
- 1.5.509
- 1.5.508
- 1.5.507
- 1.5.506
- 1.5.505
- 1.5.504
- 1.5.503
- 1.5.502
- 1.5.501
- 1.5.500
- 1.5.499
- 1.5.498
- 1.5.497
- 1.5.496
- 1.5.495
- 1.5.494
- 1.5.493
- 1.5.492
- 1.5.491
- 1.5.490
- 1.5.489
- 1.5.488
- 1.5.487
- 1.5.486
- 1.5.485
- 1.5.484
- 1.5.483
- 1.5.482
- 1.5.481
- 1.5.480
- 1.5.479
- 1.5.478
- 1.5.477
- 1.5.476
- 1.5.475
- 1.5.474
- 1.5.473
- 1.5.472
- 1.5.471
- 1.5.470
- 1.5.469
- 1.5.468
- 1.5.467
- 1.5.466
- 1.5.465
- 1.5.464
- 1.5.463
- 1.5.462
- 1.5.461
- 1.5.460
- 1.5.459
- 1.5.458
- 1.5.457
- 1.5.456
- 1.5.455
- 1.5.454
- 1.5.453
- 1.5.452
- 1.5.451
- 1.5.450
- 1.5.449
- 1.5.448
- 1.5.447
- 1.5.446
- 1.5.445
- 1.5.444
- 1.5.443
- 1.5.442
- 1.5.441
- 1.5.440
- 1.5.439
- 1.5.438
- 1.5.437
- 1.5.436
- 1.5.435
- 1.5.434
- 1.5.433
- 1.5.432
- 1.5.431
- 1.5.430
- 1.5.429
- 1.5.428
- 1.5.427
- 1.5.426
- 1.5.425
- 1.5.424
- 1.5.423
- 1.5.422
- 1.5.421
- 1.5.420
- 1.5.419
- 1.5.418
- 1.5.417
- 1.5.416
- 1.5.415
- 1.5.414
- 1.5.413
- 1.5.412
- 1.5.411
- 1.5.410
- 1.5.409
- 1.5.408
- 1.5.407
- 1.5.406
- 1.5.405
- 1.5.404
- 1.5.403
- 1.5.402
- 1.5.401
- 1.5.400
- 1.5.399
- 1.5.398
- 1.5.397
- 1.5.396
- 1.5.395
- 1.5.394
- 1.5.393
- 1.5.392
- 1.5.391
- 1.5.390
- 1.5.389
- 1.5.388
- 1.5.387
- 1.5.386
- 1.5.385
- 1.5.384
- 1.5.383
- 1.5.382
- 1.5.381
- 1.5.380
- 1.5.379
- 1.5.378
- 1.5.377
- 1.5.376
- 1.5.375
- 1.5.374
- 1.5.373
- 1.5.372
- 1.5.371
- 1.5.370
- 1.5.369
- 1.5.368
- 1.5.367
- 1.5.366
- 1.5.365
- 1.5.364
- 1.5.363
- 1.5.362
- 1.5.361
- 1.5.360
- 1.5.359
- 1.5.358
- 1.5.357
- 1.5.356
- 1.5.355
- 1.5.354
- 1.5.353
- 1.5.352
- 1.5.351
- 1.5.350
- 1.5.349
- 1.5.345
- 1.5.344
- 1.5.343
- 1.5.342
- 1.5.341
- 1.5.340
- 1.5.339
- 1.5.338
- 1.5.337
- 1.5.336
- 1.5.335
- 1.5.334
- 1.5.333
- 1.5.332
- 1.5.331
- 1.5.330
- 1.5.329
- 1.5.328
- 1.5.327
- 1.5.326
- 1.5.325
- 1.5.324
- 1.5.323
- 1.5.322
- 1.5.321
- 1.5.320
- 1.5.319
- 1.5.318
- 1.5.317
- 1.5.316
- 1.5.315
- 1.5.314
- 1.5.313
- 1.5.312
- 1.5.311
- 1.5.310
- 1.5.309
- 1.5.308
- 1.5.307
- 1.5.306
- 1.5.305
- 1.5.304
- 1.5.303
- 1.5.302
- 1.5.301
- 1.5.300
- 1.5.299
- 1.5.298
- 1.5.297
- 1.5.296
- 1.5.295
- 1.5.294
- 1.5.293
- 1.5.292
- 1.5.291
- 1.5.290
- 1.5.289
- 1.5.288
- 1.5.287
- 1.5.286
- 1.5.285
- 1.5.284
- 1.5.283
- 1.5.282
- 1.5.281
- 1.5.280
- 1.5.279
- 1.5.278
- 1.5.277
- 1.5.276
- 1.5.275
- 1.5.274
- 1.5.273
- 1.5.272
- 1.5.271
- 1.5.270
- 1.5.269
- 1.5.268
- 1.5.267
- 1.5.266
- 1.5.265
- 1.5.264
- 1.5.263
- 1.5.262
- 1.5.261
- 1.5.260
- 1.5.259
- 1.5.258
- 1.5.257
- 1.5.256
- 1.5.255
- 1.5.254
- 1.5.253
- 1.5.252
- 1.5.251
- 1.5.250
- 1.5.249
- 1.5.248
- 1.5.247
- 1.5.246
- 1.5.245
- 1.5.244
- 1.5.243
- 1.5.242
- 1.5.241
- 1.5.240
- 1.5.239
- 1.5.238
- 1.5.237
- 1.5.236
- 1.5.235
- 1.5.234
- 1.5.233
- 1.5.232
- 1.5.231
- 1.5.230
- 1.5.229
- 1.5.228
- 1.5.227
- 1.5.226
- 1.5.225
- 1.5.224
- 1.5.223
- 1.5.222
- 1.5.221
- 1.5.220
- 1.5.219
- 1.5.218
- 1.5.217
- 1.5.216
- 1.5.215
- 1.5.214
- 1.5.213
- 1.5.212
- 1.5.211
- 1.5.210
- 1.5.209
- 1.5.208
- 1.5.207
- 1.5.206
- 1.5.205
- 1.5.204
- 1.5.203
- 1.5.202
- 1.5.201
- 1.5.200
- 1.5.199
- 1.5.198
- 1.5.197
- 1.5.196
- 1.5.195
- 1.5.194
- 1.5.193
- 1.5.192
- 1.5.191
- 1.5.190
- 1.5.189
- 1.5.188
- 1.5.187
- 1.5.186
- 1.5.185
- 1.5.184
- 1.5.183
- 1.5.182
- 1.5.181
- 1.5.180
- 1.5.179
- 1.5.178
- 1.5.177
- 1.5.176
- 1.5.175
- 1.5.174
- 1.5.173
- 1.5.172
- 1.5.171
- 1.5.170
- 1.5.169
- 1.5.168
- 1.5.167
- 1.5.166
- 1.5.165
- 1.5.164
- 1.5.163
- 1.5.162
- 1.5.161
- 1.5.160
- 1.5.159
- 1.5.158
- 1.5.157
- 1.5.156
- 1.5.155
- 1.5.154
- 1.5.153
- 1.5.152
- 1.5.151
- 1.5.150
- 1.5.149
- 1.5.148
- 1.5.147
- 1.5.146
- 1.5.145
- 1.5.144
- 1.5.143
- 1.5.142
- 1.5.141
- 1.5.140
- 1.5.139
- 1.5.138
- 1.5.137
- 1.5.136
- 1.5.135
- 1.5.134
- 1.5.133
- 1.5.132
- 1.5.131
- 1.5.130
- 1.5.129
- 1.5.128
- 1.5.127
- 1.5.126
- 1.5.125
- 1.5.124
- 1.5.123
- 1.5.122
- 1.5.121
- 1.5.120
- 1.5.119
- 1.5.118
- 1.5.117
- 1.5.116
- 1.5.115
- 1.5.114
- 1.5.113
- 1.5.112
- 1.5.111
- 1.5.110
- 1.5.109
- 1.5.108
- 1.5.107
- 1.5.106
- 1.5.105
- 1.5.104
- 1.5.103
- 1.5.102
- 1.5.101
- 1.5.100
- 1.5.99
- 1.5.98
- 1.5.97
- 1.5.96
- 1.5.95
- 1.5.94
- 1.5.93
- 1.5.92
- 1.5.91
- 1.5.90
- 1.5.89
- 1.5.88
- 1.5.87
- 1.5.86
- 1.5.85
- 1.5.84
- 1.5.83
- 1.5.82
- 1.5.81
- 1.5.80
- 1.5.79
- 1.5.78
- 1.5.77
- 1.5.76
- 1.5.75
- 1.5.74
- 1.5.73
- 1.5.72
- 1.5.71
- 1.5.70
- 1.5.69
- 1.5.68
- 1.5.67
- 1.5.66
- 1.5.65
- 1.5.64
- 1.5.63
- 1.5.62
- 1.5.61
- 1.5.60
- 1.5.59
- 1.5.58
- 1.5.57
- 1.5.56
- 1.5.55
- 1.5.54
- 1.5.53
- 1.5.52
- 1.5.51
- 1.5.50
- 1.5.49
- 1.5.48
- 1.5.47
- 1.5.46
- 1.5.45
- 1.5.44
- 1.5.43
- 1.5.42
- 1.5.41
- 1.5.40
- 1.5.39
- 1.5.38
- 1.5.37
This package is auto-updated.
Last update: 2026-10-09 15:20:56 UTC
README
Integrates the Simple Datatables library (https://github.com/fiduswriter/simple-datatables/) as a Symfony UX Stimulus controller, and provides Twig components for common rendering.
Migrating to Grid Bundle
Simple Datatables remains supported and is appropriate when a lighter table library meets the application’s needs. It is not deprecated. If an application already uses survos/api-grid-bundle, use survos/grid-bundle for its fast in-memory tables: the shared Grid dependency is already included. If an in-memory table is sufficient and the application does not already use API Grid, ask the application owner to choose Grid or simple-datatables before migrating. Use API Grid when API-backed pagination and filtering are required. Grid is heavier than simple-datatables, but gives both paths one DataTables implementation and Bootstrap 5 / Tabler theme. Optional extensions load lazily. This guide describes an explicit application migration; installing Grid does not automatically replace existing components.
1. Inventory and install
Find uses of simple_datatables, simple_item_grid, Survos\SimpleDatatables, direct Stimulus mounts, custom CSS and JavaScript hooks. Check both backend="simple" and backend="ux" tables. Record representative routes and importmap pin counts before changing them.
Install a published Grid release that includes the shared base, extensions and options component properties. Confirm the release is available through your configured Composer repositories; an older release can install successfully without those features.
composer require survos/grid-bundle php bin/console importmap:install php bin/console cache:clear
For local bundle development, install normally first, then run the mono checkout's linking tool:
/path/to/mono/link /path/to/application
Never add Composer type: path repositories or fabricated package-version overrides to application manifests or lockfiles. mono/link changes the local vendor tree; deployment must use published packages and a portable Composer lockfile. Locally linked code is not proof that the locked release contains the same features.
2. Replace a table component
Before:
<twig:simple_datatables :data="products" :columns="['name', 'price']" perPage="20" backend="ux" :trans="false" scrollY=""> <twig:block name="price">{{ row.price|number_format(2) }}</twig:block> </twig:simple_datatables>
After:
<twig:grid :data="products" :columns="['name', 'price']" :pageLength="20" :trans="false" scrollY="" :info="true"> <twig:block name="price">{{ row.price|number_format(2) }}</twig:block> </twig:grid>
| Existing usage | Grid migration |
|---|---|
simple_datatables |
grid |
perPage |
pageLength |
backend="simple" or backend="ux" |
Remove; Grid uses DataTables |
data, named columns, column blocks |
Preserve; local blocks still receive row, column, idx |
search, info, useDatatables, condition, tableId, tableClasses |
Supported; set explicitly where behavior matters |
| Translation and scrolling defaults | Set trans and scrollY explicitly to preserve the old page |
activate |
Remove; use useDatatables to control enhancement |
Survos\SimpleDatatables\Model\Column objects |
Rebuild as Survos\Grid\Model\Column or supported column arrays; do not pass legacy objects |
simple_item_grid |
Review and migrate to item_grid; its field blocks receive data, not row |
A remoteUrl grid fetches its collection once and paginates/searches in the browser. Supply explicit named columns. Local PHP Twig blocks do not render remote rows. Use API Grid for server-side pagination, facets and browser-side Twig rendering; it requires API Platform and is a separate migration.
Do not merely rename the controller on a manually authored <table>. Prefer the Twig component, which puts the Grid controller on a stable wrapper with a table target. DataTables moves the table during initialization; mounting the controller on that table can cause repeated connect/disconnect cycles. Grid's controller identifier is survos--grid-bundle--grid.
3. Configure assets and optional features
Keep the controller lazy and CSS imports inside the controller:
{
"controllers": {
"@survos/grid-bundle": {
"grid": {"enabled": true, "fetch": "lazy", "autoimport": {}}
}
}
}
Grid owns DataTables pins through its assets/package.json → symfony.importmap. Compare existing application versions with that manifest: importmap:install downloads existing pins but does not upgrade all stale versions. Use importmap:require package@version for the required corrections. Do not add DataTables CSS to global controllers.json autoimports.
Port only features the application uses. For example, responsive behavior needs both the extension and its configuration:
<twig:grid :data="products" :columns="['name', 'price']" :extensions="['responsive']" :options="{responsive: true}" />
Review old simple-datatables/Pentiminax events, options and CSS selectors individually; these are not interchangeable APIs. See the Grid README for supported extensions and the API Grid README for the server-driven path.
4. Verify, then remove legacy dependencies
Check search, both sort directions, page sizes, pagination, empty data, links, custom cells and Turbo navigation away/back. Test any remote endpoint and requested extensions. Inspect the browser console and network: a plain Grid should not download unused extensions, and pages without tables should not load DataTables unless another consumer requires it. Compare pin counts before/after separately from actual network downloads.
Showcase's /browse page provides a local reference over 23 sites; tree-demo's /playground/topics compares Grid backends. Showcase's base-Grid smoke test does not establish API Grid facet or pagination correctness. Repeat verification using the published packages without local links before deployment.
Once all consumers have moved:
composer why survos/simple-datatables-bundle composer why pentiminax/ux-datatables composer remove survos/simple-datatables-bundle
A transitive consumer such as survos/folio-bundle may still require the old bundle. Migrate that consumer first; do not force removal. Remove direct Pentiminax requirements only after its own call sites are migrated. Inspect recipe cleanup and remove unused legacy bundle configuration, routes, controller registrations and importmap pins only when no remaining consumer needs them. Keep this cleanup scoped to the application being migrated.
Stimulus Controller (Tables)
To turn any HTML <table> into a datatable, simply add the stimulus controller to the tag:
<table class="table" {{ stimulus_controller('@survos/simple-datatables-bundle/table', { perPage: 5, search: true }) }}>
Twig Component: simple_datatables
This component renders a <table> and wires up the datatable stimulus controller.
{% set columns = [
{ name: 'id' },
{ name: 'title', title: 'name' },
'brand',
'price',
] %}
<twig:simple_datatables
perPage="20"
:columns="columns"
:data="products"
>
<twig:block name="price">
${{ row.price|number_format(2) }}
</twig:block>
</twig:simple_datatables>
Notes:
columnscan be strings ('price') or arrays passed toSurvos\SimpleDatatables\Model\Column(e.g.{ name: 'price', title: 'Price' }).- Inside a column block you typically get
row,column,idx.
Twig Component: simple_item_grid
simple_item_grid renders a single item/record as a definition list (<dl>), which is handy for a “show” page.
Component: Survos\SimpleDatatables\Components\ItemGridComponent.
Template: templates/components/item.html.twig.
Basic usage
simple_item_grid renders the fields you list in columns for a single associative array or object passed as data:
<twig:simple_item_grid :data="product" :columns="['title', 'brand', 'price']" />
Columns
Columns can be strings or Column-style arrays. For the item grid template, name and title are the relevant fields.
{% set columns = [
{ name: 'title', title: 'Name' },
{ name: 'price', title: 'Price' },
'brand',
] %}
<twig:simple_item_grid :data="product" :columns="columns" />
Excluding fields
The exclude option is used when the component auto-generates columns. Auto-generation currently only kicks in when data is a list of rows and columns is omitted.
<twig:simple_item_grid :data="items" exclude="internalNotes,ssn" />
Custom rendering with blocks
For custom rendering, define a block named after the column’s name. The block receives data.
<twig:simple_item_grid :data="product" :columns="['title','price']"> <twig:block name="price"> ${{ data.price|number_format(2) }} </twig:block> </twig:simple_item_grid>
Stimulus
The wrapper <div> can be wired to a stimulus controller via stimulusController.
By default it uses @survos/grid/item_grid.
Complete Project
Cut and paste to create a new Symfony project with a dynamic, searchable datatable, without writing a single line of JavaScript. No webpack or build step either.
symfony new simple-datatables-demo --webapp && cd simple-datatables-demo rm .git -rf composer config extra.symfony.allow-contrib true composer req survos/simple-datatables-bundle bin/console make:controller Simple -i cat > templates/simple.html.twig <<END {% extends 'base.html.twig' %} {% block body %} <table class="table" {{ stimulus_controller('@survos/simple-datatables-bundle/table', {perPage: 5, search: true}) }}> <thead> <tr> <th>abbr</th> <th>name</th> <th>number</th> </tr> </thead> <tbody> {% for j in 1..12 %} <tr> <td>{{ j |date('2023-' ~ j ~ '-01') |date('M') }}</td> <td>{{ j |date('2023-' ~ j ~ '-01') |date('F') }}</td> <td>{{ j }}</td> </tr> {% endfor %} </tbody> </table> {% endblock %} END symfony server:start -d symfony open:local --path=/simple
Or even easier, use the Twig component. To simplify the example we're going to add the fetch and json_decode functions to Twig; normally that would be done in the controller, but the copy/paste is faster this way.
composer require zenstruck/twig-service-bundle cat > config/packages/zenstruck_twig_service.yaml <<END zenstruck_twig_service: functions: fetch: file_get_contents # available as "fn_fetch()" in twig json_decode: json_decode END cat > templates/simple.html.twig <<'END' {% extends 'base.html.twig' %} {% block body %} {% set columns = [ {name: 'id'}, {name: 'title', title: 'name'}, 'brand', 'price' ] %} <twig:simple_datatables perPage="20" :caller="_self" :columns="columns" :data="fn_json_decode(fn_fetch('https://dummyjson.com/products')).products" > <twig:block name="price"> ${{ row.price|number_format(2) }} </twig:block> </twig:simple_datatables> {% endblock %} END symfony server:start -d symfony open:local --path=/simple
Troubleshooting a static table
Use @survos/simple-datatables-bundle/table in stimulus_controller(). Older README examples omitted -bundle, producing an identifier that did not match the registered UX controller. Rendered data-controller attributes alone do not prove that Stimulus connected. See issue #2.
The rendered identifier should be survos--simple-datatables-bundle--table. Check that assets/controllers.json enables table under @survos/simple-datatables-bundle, the application starts Stimulus, and the browser console has no missing-import errors. Run php bin/console importmap:install after installation. The controller exposes perPage and search; it does not expose a sortable Stimulus value.
For Survos applications that also need API-backed tables, survos/grid-bundle provides the shared DataTables base used by survos/api-grid-bundle. It is a heavier foundation than simple-datatables, chosen for shared behavior and integration across the platform. This is a migration direction, not a claim that existing simple-datatables applications have already migrated.