simple_datatables 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc
CHANGED
@@ -24,7 +24,7 @@ There are two ways to map awesome Datatables plugin request fields for Rails.
|
|
24
24
|
This gem provides interface for the second way.
|
25
25
|
To use it you should do the following easy three steps:
|
26
26
|
|
27
|
-
Create simple meta_search and will_paginate controller action as usual and add ".datatables" format
|
27
|
+
Create simple meta_search and will_paginate (optionally) controller action as usual and add ".datatables" format
|
28
28
|
|
29
29
|
respond_to :html, :datatables
|
30
30
|
|
@@ -44,13 +44,23 @@ Create Jsonify view with column values for columns listed in aoColumns. See exam
|
|
44
44
|
|
45
45
|
This gem uses:
|
46
46
|
* meta_search for nice search and sort request syntax mapping
|
47
|
-
* will_paginate for nice pagination request syntax mapping
|
48
47
|
* jsonify for simple output generation
|
49
48
|
|
49
|
+
This gem provides integration with:
|
50
|
+
* will_paginate for nice pagination request syntax mapping
|
51
|
+
|
50
52
|
Gem works only with rails 3.1.
|
51
53
|
|
52
54
|
Gem includes datatables library and fnSetFilteringDelay plugin so you haven't include it by yourself.
|
53
55
|
|
56
|
+
== Pagination
|
57
|
+
|
58
|
+
Simple_datatables is compatible with will_paginate. Datatables will provide you "page" and "per_page" request params.
|
59
|
+
|
60
|
+
If you do not use pagination do not forget to save search result to some variable with meta_search relation method:
|
61
|
+
|
62
|
+
@products = Product.search(params[:search]).relation
|
63
|
+
|
54
64
|
== Search for all fields
|
55
65
|
|
56
66
|
Note that fulltext search will work only with text fields due to meta_search restrictions. To prevent errors use bSearchable: false for non-text columns in aoColumns field.
|
@@ -1,10 +1,29 @@
|
|
1
|
+
total_entries = nil
|
2
|
+
current_page_entries = 0
|
3
|
+
|
1
4
|
instance_variables.each do |vn|
|
2
5
|
v = instance_variable_get(vn)
|
6
|
+
next if v.class.name.nil?
|
7
|
+
if v.class.name.start_with?("MetaSearch::Searches") and v.respond_to?('size')
|
8
|
+
current_page_entries = v.size
|
9
|
+
end
|
10
|
+
if v.class.name.start_with?("ActiveRecord::Relation") and v.respond_to?('size')
|
11
|
+
current_page_entries = v.size
|
12
|
+
end
|
13
|
+
if v.class.name.start_with?("Array") and v.respond_to?('size') and (current_page_entries == 0)
|
14
|
+
current_page_entries = v.size
|
15
|
+
end
|
3
16
|
if v.respond_to?('total_entries')
|
4
|
-
|
5
|
-
|
17
|
+
total_entries = v.total_entries
|
18
|
+
current_page_entries = v.size
|
19
|
+
break
|
6
20
|
end
|
7
21
|
end
|
22
|
+
|
23
|
+
total_entries = current_page_entries if total_entries.nil?
|
24
|
+
|
25
|
+
json.iTotalRecords current_page_entries
|
26
|
+
json.iTotalDisplayRecords total_entries
|
8
27
|
json.sEcho params["sEcho"].to_i
|
9
28
|
json.aaData do
|
10
29
|
json.ingest! yield
|
data/simple_datatables.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_datatables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-09-01 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &31780128 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,21 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.1.0.rc8
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: will_paginate
|
27
|
-
requirement: &24603120 !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
|
-
requirements:
|
30
|
-
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 3.0.0
|
33
|
-
type: :runtime
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *24603120
|
24
|
+
version_requirements: *31780128
|
36
25
|
- !ruby/object:Gem::Dependency
|
37
26
|
name: meta_search
|
38
|
-
requirement: &
|
27
|
+
requirement: &31779408 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
29
|
requirements:
|
41
30
|
- - ~>
|
@@ -43,10 +32,10 @@ dependencies:
|
|
43
32
|
version: 1.1.0.pre2
|
44
33
|
type: :runtime
|
45
34
|
prerelease: false
|
46
|
-
version_requirements: *
|
35
|
+
version_requirements: *31779408
|
47
36
|
- !ruby/object:Gem::Dependency
|
48
37
|
name: jsonify-rails
|
49
|
-
requirement: &
|
38
|
+
requirement: &31778484 !ruby/object:Gem::Requirement
|
50
39
|
none: false
|
51
40
|
requirements:
|
52
41
|
- - ! '>='
|
@@ -54,7 +43,7 @@ dependencies:
|
|
54
43
|
version: '0'
|
55
44
|
type: :runtime
|
56
45
|
prerelease: false
|
57
|
-
version_requirements: *
|
46
|
+
version_requirements: *31778484
|
58
47
|
description: Simple datatables to rails mapping using meta_search, will_paginage and
|
59
48
|
jsonify
|
60
49
|
email:
|