datatablesnet 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/app/views/datatablesnet/_table.html.haml +1 -1
- data/lib/datatablesnet/datatable.rb +48 -4
- data/lib/datatablesnet/version.rb +1 -1
- metadata +3 -3
data/Gemfile.lock
CHANGED
@@ -66,7 +66,7 @@ module Datatable
|
|
66
66
|
:auto_scroll => "bScrollInfinite",
|
67
67
|
:pagination_type => "sPaginationType",
|
68
68
|
:paginate => "bPaginate",
|
69
|
-
:save_state => "bStateSave"
|
69
|
+
:save_state => "bStateSave",
|
70
70
|
}
|
71
71
|
|
72
72
|
|
@@ -74,11 +74,14 @@ module Datatable
|
|
74
74
|
{
|
75
75
|
:show_actions => false,
|
76
76
|
:per_page => 25,
|
77
|
-
:toolbar_external => false
|
77
|
+
:toolbar_external => false,
|
78
|
+
:show_only_when_searched => false
|
78
79
|
}.merge(options)
|
79
80
|
|
80
|
-
|
81
|
-
|
81
|
+
if options[:data_url].present?
|
82
|
+
url = URI::split(options[:data_url])
|
83
|
+
end
|
84
|
+
|
82
85
|
index = 0
|
83
86
|
columns.each do |column|
|
84
87
|
column[:label] = field_to_label(column[:field]) unless column[:label].present?
|
@@ -94,6 +97,10 @@ module Datatable
|
|
94
97
|
index += 1
|
95
98
|
end
|
96
99
|
|
100
|
+
if options[:show_only_when_searched]
|
101
|
+
options[:data_url] << "&show_only_when_searched=true"
|
102
|
+
end
|
103
|
+
|
97
104
|
if options[:toolbar].present? or options[:toolbar_external]
|
98
105
|
options[:dom]='<"toolbar">lfrtip'
|
99
106
|
end
|
@@ -105,6 +112,11 @@ module Datatable
|
|
105
112
|
end
|
106
113
|
end
|
107
114
|
|
115
|
+
if options[:language].present?
|
116
|
+
puts "language present"
|
117
|
+
table_options["oLanguage"] = datatable_get_language_defs(options[:language])
|
118
|
+
end
|
119
|
+
|
108
120
|
table_options["fnInfoCallback"] = NoEscape.new(options[:info_callback]) if options[:info_callback].present?
|
109
121
|
|
110
122
|
table_options["aoColumns"] = datatable_get_column_defs(options,columns)
|
@@ -115,6 +127,21 @@ module Datatable
|
|
115
127
|
render :partial => "datatablesnet/table", :locals => { :table_id => id, :columns => columns, :rows => rows, :config => config}
|
116
128
|
end
|
117
129
|
|
130
|
+
def datatable_get_language_defs options
|
131
|
+
language_options_map = {:info_empty => "sInfoEmpty",
|
132
|
+
:info_filtered => "sInfoFiltered",
|
133
|
+
:empty_table => "sEmptyTable",
|
134
|
+
:zero_records => "sZeroRecords"}
|
135
|
+
|
136
|
+
language_options = {}
|
137
|
+
language_options_map.each do |k,v|
|
138
|
+
if options[k].present?
|
139
|
+
language_options[v] = options[k]
|
140
|
+
end
|
141
|
+
end
|
142
|
+
language_options
|
143
|
+
end
|
144
|
+
|
118
145
|
def datatable_get_column_defs options, columns
|
119
146
|
column_defs = []
|
120
147
|
column_options_map = {:width => "sWidth",
|
@@ -201,6 +228,13 @@ module Datatable
|
|
201
228
|
columns = []
|
202
229
|
order_by = {}
|
203
230
|
filter_by = {}
|
231
|
+
|
232
|
+
if params["show_only_when_searched"].present?
|
233
|
+
grid_options[:show_only_when_searched] = true
|
234
|
+
else
|
235
|
+
grid_options[:show_only_when_searched] = false
|
236
|
+
end
|
237
|
+
|
204
238
|
(0..params[:iColumns].to_i-2).each do |index|
|
205
239
|
column = {}
|
206
240
|
column[:field] = params["column_field_#{index}"]
|
@@ -340,6 +374,16 @@ module Datatable
|
|
340
374
|
end
|
341
375
|
end
|
342
376
|
|
377
|
+
if grid_options[:show_only_when_searched]
|
378
|
+
if grid_options[:search_by].empty?
|
379
|
+
json_data = {:sEcho => params[:sEcho],
|
380
|
+
:iTotalRecords => 0,
|
381
|
+
:iTotalDisplayRecords => 0,
|
382
|
+
:aaData => []}
|
383
|
+
return json_data
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
343
387
|
# Build filter by
|
344
388
|
options[:conditions] = build_condition_internal(klass, grid_options, options[:conditions].present? ? options[:conditions] : nil)
|
345
389
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 6
|
9
|
+
version: 1.1.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Matt Fields
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-09-
|
17
|
+
date: 2011-09-30 00:00:00 +03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|