You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then we need to map the records retrieved by the `get_raw_records` method to the real values we want to display :
@@ -225,7 +239,7 @@ def data
225
239
last_name: record.last_name,
226
240
email: record.email,
227
241
bio: record.bio,
228
-
DT_RowId: record.id, # This will set the id attribute on the corresponding <tr> in the datatable
242
+
DT_RowId: record.id, # This will automagically set the id attribute on the corresponding <tr> in the datatable
229
243
}
230
244
end
231
245
end
@@ -398,6 +412,8 @@ class MyCustomDatatable < AjaxDatatablesRails::Base
398
412
end
399
413
```
400
414
415
+
### Using view decorators
416
+
401
417
If you want to keep things tidy in the data mapping method, you could use
402
418
[Draper](https://github.com/drapergem/draper) to define column mappings like below.
403
419
@@ -640,7 +656,9 @@ In the end, it's up to the developer which model(s), scope(s), relationship(s)
640
656
(or else) to employ inside the datatable class to retrieve records from the
641
657
database.
642
658
643
-
### Creating indices for Postgresql
659
+
## Pro Tips
660
+
661
+
### Create indices for Postgresql
644
662
645
663
In order to speed up the `ILIKE` queries that are executed when using the default configuration, you might want to consider adding some indices.
646
664
For postgresql, you are advised to use the [gin/gist index type](http://www.postgresql.org/docs/current/interactive/pgtrgm.html).
@@ -683,6 +701,71 @@ $ bundle install
683
701
684
702
That's all :) ([Automatically prefer Yajl or JSON backend over Yaml, if available](https://github.com/rails/rails/commit/63bb955a99eb46e257655c93dd64e86ebbf05651))
685
703
704
+
### Use HTTP `POST` method
705
+
706
+
Use HTTP `POST` method to avoid `414 Request-URI Too Large` error. See : [#278](https://github.com/jbox-web/ajax-datatables-rails/issues/278).
707
+
708
+
You can easily define a route concern in `config/routes.rb` and reuse it when you need it :
0 commit comments