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
* A fresh start. Changes base class name to: `DatatablesRails`.
4
+
* A fresh start. Sets base class name to: `AjaxDatatablesRails::Base`.
5
5
* Extracts pagination functions to mixable modules.
6
6
* A user would have the option to stick to the base
7
-
`DatatablesRails::Extensions::SimplePaginator` or replace it with
8
-
`DatatablesRails::Extensions::Kaminari` or
9
-
`DatatablesRails::Extensions::WillPaginate`, depending on what he/she is using to handle record pagination.
10
-
* Removes dependency to pass in a model name to the generator. This way, the developer has more flexibility to implement whatever datatable feature is required.
11
-
* Datatable constructor accepts an optional `options` hash to provide more flexibility. See [README](https://github.com/antillas21/ajax-datatables-rails/blob/master/README.md) for examples.
7
+
`AjaxDatatablesRails::Extensions::SimplePaginator` or replace it with
8
+
`AjaxDatatablesRails::Extensions::Kaminari` or
9
+
`AjaxDatatablesRails::Extensions::WillPaginate`, depending on what he/she is using to handle record pagination.
10
+
* Removes dependency to pass in a model name to the generator. This way,
11
+
the developer has more flexibility to implement whatever datatable feature is required.
12
+
* Datatable constructor accepts an optional `options` hash to provide
13
+
more flexibility.
14
+
See [README](https://github.com/antillas21/ajax-datatables-rails/blob/master/README.mds#options) for examples.
15
+
* Sets generator inside the `Rails` namespace. To generate an
16
+
`AjaxDatatablesRails` child class, just execute the
17
+
generator like this: `$ rails generate datatable NAME`.
@@ -13,9 +15,11 @@ Datatables is a nifty jquery plugin that adds the ability to paginate, sort, and
13
15
14
16
`ajax-datatables-rails` is a wrapper around datatable's ajax methods that allow synchronization with server-side pagination in a rails app. It was inspired by this [Railscast](http://railscasts.com/episodes/340-datatables). I needed to implement a similar solution in a couple projects I was working on so I extracted it out into a gem.
15
17
16
-
## ORM Support
18
+
## ORM support
17
19
18
-
Currently, it only supports `ActiveRecord` as ORM for performing database queries.
20
+
Currently `AjaxDatatablesRails` only supports `ActiveRecord` as ORM for performing database queries.
21
+
22
+
Adding support for `Sequel`, `Mongoid` and `MongoMapper` is a planned feature for this gem. If you'd be interested in contributing to speed development, please [open an issue](https://github.com/antillas21/ajax-datatables-rails/issues/new) and get in touch.
19
23
20
24
## Installation
21
25
@@ -37,7 +41,9 @@ Run the following command:
37
41
$ rails generate datatable User
38
42
39
43
40
-
This will generate a file named `user_datatable.rb` in `app/datatables`. Open the file and customize in the functions as directed by the comments
44
+
This will generate a file named `user_datatable.rb` in `app/datatables`. Open the file and customize in the functions as directed by the comments.
45
+
46
+
Take a look [here](#generator-syntax) for an explanation about the generator syntax.
41
47
42
48
### Customize
43
49
```ruby
@@ -60,9 +66,9 @@ def searchable_columns
60
66
end
61
67
```
62
68
63
-
* For `extensions`, just uncomment the paginator you would like to use, given
69
+
* For `paginator options`, just uncomment the paginator you would like to use, given
64
70
the gems bundled in your project. For example, if your models are using `Kaminari`, uncomment `AjaxDatatablesRails::Extensions::Kaminari`. You may remove all commented lines.
65
-
*`SimplePaginator` falls back to passing `offset` and `limit` at the database level (through `ActiveRecord` of course).
71
+
*`SimplePaginator`is the most basic of them all, it falls back to passing `offset` and `limit` at the database level (through `ActiveRecord` of course, as that is the only ORM supported for the time being).
66
72
67
73
* For `sortable_columns`, assign an array of the database columns that correspond to the columns in our view table. For example `[users.f_name, users.l_name, users.bio]`. This array is used for sorting by various columns.
68
74
@@ -123,6 +129,8 @@ def get_raw_records
123
129
end
124
130
```
125
131
132
+
Obviously, you can construct your query as required for the use case the datatable is used. Example: `User.active.with_recent_messages`.
133
+
126
134
### Controller
127
135
Set up the controller to respond to JSON
128
136
@@ -135,6 +143,8 @@ def index
135
143
end
136
144
```
137
145
146
+
Don't forget to make sure the proper route has been added to `config/routes.rb`.
147
+
138
148
### View
139
149
* Set up an html `<table>` with a `<thead>` and `<tbody>`
0 commit comments