Skip to content

Commit d14e01f

Browse files
committed
Expand docs
1 parent 38e29ca commit d14e01f

File tree

1 file changed

+40
-27
lines changed

1 file changed

+40
-27
lines changed

docs/source/index.html.md

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -148,56 +148,69 @@ datatables:
148148
translation_domain: messages
149149
```
150150
151-
Global configuration of the bundle is done in your config file. The default configuration is shown here,
151+
Global configuration of the bundle is done in your Symfony config file. The default configuration is shown here,
152152
and should be fine in most cases. Most settings can be overridden per table, but for most applications
153153
you will want to make changes at the global level so they are applied everywhere, providing a uniform
154154
look and feel.
155155
156-
The following settings only exist at the configuration level:
156+
The following settings exist at the configuration level:
157157
158158
Option | Type | Description
159159
------ | ---- | ------- | -----------
160+
language_from_cdn | bool | Load i18n files from DataTables CDN or from Symfony Translations.
161+
options | object | Default options that will be passed to DataTables clientside initialization.
162+
method | string | Either `GET` or `POST` to indicate which HTTP method to use for callbacks.
163+
renderer | string | Service used to render the table HTML, which must implement the <code>DataTableRendererInterface</code>.
160164
template | string | Default template to be used for rendering the basic HTML table in your templates.
161-
renderer | string | Service used to render the table HTML, which must implement the <code>DataTableRendererInterface</code>.
165+
template_parameters | object | Default parameters to be passed to the template during rendering.
166+
translation_domains | string | Default Symfony Translation Domain used where translations are used.
162167

163-
The other settings correspond to table level settings, and the `options` are passed (almost) verbatim
164-
to the DataTables clientside constructor. Refer to the sections below for details on individual settings
165-
and options.
168+
All settings can be overridden on individual tables by calling the corresponding setter function,
169+
ie. `setLanguageFromCDN(bool)`.
166170

167-
## Settings
171+
The `options` are passed (almost) verbatim to the DataTables clientside constructor. Refer to the
172+
[external documentation](https://datatables.net/reference/option/) below for details on individual
173+
options. Only options which are meaningful to be defined serverside can be set at this level, so
174+
setting callbacks and events is not possible. These are however easily set on the Javascript end.
168175

169-
These settings can all be defined both at the global config level and overridden per table.
176+
# Core concepts
170177

171-
Setting | Type | Default | Description
172-
------- | ---- | ------- | -----------
173-
name | string | dt | The name of the DataTable. Used mainly to separate callbacks in case multiple tables are used on the same page.
174-
method | string | POST | Use `GET` or `POST` to define the HTTP method used by callbacks.
175-
class_name | string | | Class to apply to the `<table>` element in generated tables. Separate multiple classes with a space.
176-
column_filter | string | *null* | When using column level filters set this to `thead`, `tfoot` or `both` to specify where to render them.
177-
language_from_cdn | bool | true | Either loads DataTables' own translations from CDN (default) or have them provided by your own Symfony translation files.
178-
translation_domain | string | messages | Default translation domain used in the table structure.
178+
This chapter details various base building blocks used in the bundle.
179179

180-
## Options
180+
## Adapters
181181

182-
# Core concepts
182+
Adapters are the core elements bridging DataTables functionality to their underlying data source.
183+
Popular implementations for common data sources are provided, and more are welcomed.
183184

184-
## DataTable types
185+
An adapter is called by the bundle when a request for data has been formulated, including search
186+
and sorting criteria, and returns a result set with metadata on record counts.
185187

186-
Having the table configuration in your controller is convenient, but not practical for reusable or
187-
extensible tables, or highly customized tables.
188+
## Columns
188189

189-
In the example above we could also create a class `DataTable\Type\PresidentsTableType` in our app bundle,
190-
and make it implement `Omines\DataTablesBundle\DataTableTypeInterface`. We can then use:
190+
Column classes derive from `AbstractColumn`, and implement the transformations required to convert
191+
raw data into output ready for rendering in a DataTable.
192+
193+
## DataTable types
191194

192195
```php?start_inline=1
193196
$table = $this->createDataTableFromType(PresidentsTableType::class)
194197
->handleRequest($request);
195198
```
196-
This ensures your controllers stay lean and short, and only delegate tasks. Of course you can modify
197-
the base type to fit the controller's specific needs before calling `handleRequest`.
198199

199-
If you need dependencies injected just register `PresidentsTableType` as a service in the container, and
200-
tag it with `datatables.type`. Or just use `autoconfigure:true` as is recommended Symfony practice.
200+
Having the table configuration in your controller is convenient, but not practical for reusable or
201+
extensible tables, or highly customized tables. In the example above we could also create a class
202+
`DataTable\Type\PresidentsTableType` in our app bundle, and make it implement
203+
`Omines\DataTablesBundle\DataTableTypeInterface`. We can then use the code illustrated here to
204+
instantiate the reusable class in the controller.
205+
206+
This ensures your controllers stay lean and short, and only delegate tasks. The first parameter
207+
takes either a Fully Qualified Class Name (FQCN) to instantiate the class dynamically, or a
208+
registered service with a `datatables.type` tag. Use a service if you need to inject dependencies
209+
dynamically. When using Symfony's autoconfiguration the tag will be applied automatically.
210+
211+
Of course you can modify the base type to fit the controller's specific needs before calling
212+
`handleRequest`. Secondly, the `createDataTableFromType` function accepts an array as a second
213+
argument which is passed to the type class for parametrized instantiation.
201214

202215
# Adapters
203216

0 commit comments

Comments
 (0)