jqgrid_for_rails 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +11 -1
- data/README.rdoc +72 -39
- data/lib/app/helpers/jqgrids_helper.rb +63 -69
- data/lib/jqgrid_for_rails/controllers/helpers.rb +4 -4
- data/lib/jqgrid_for_rails/version.rb +1 -1
- data/test/controllers/helpers_test.rb +5 -0
- data/test/jqgrids_helper_test.rb +39 -35
- metadata +3 -7
data/CHANGELOG.rdoc
CHANGED
@@ -1,8 +1,18 @@
|
|
1
|
+
== 1.0.0
|
2
|
+
|
3
|
+
* enhancements
|
4
|
+
* Support for chained functions.
|
5
|
+
* The 'jqgrid' method is renamed and rewritten to fully support calls to jqgrid apis.
|
6
|
+
* Get the page number for the json response from the will_paginate resultset.
|
7
|
+
|
8
|
+
* bug fixes
|
9
|
+
* Fix order_by_from_params when sidx is blank.
|
10
|
+
|
1
11
|
== 0.2.0
|
2
12
|
|
3
13
|
* enhancements
|
4
14
|
* Navigator options fully supported.
|
5
15
|
|
6
|
-
* bug
|
16
|
+
* bug fixes
|
7
17
|
* Get pager id from the options hash in any of the formats accepted by
|
8
18
|
jqGrid.
|
data/README.rdoc
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
== JqgridForRails
|
2
2
|
|
3
|
-
This is a simple plug-in to create JqGrid
|
3
|
+
This is a simple plug-in to create a JqGrid[http://www.trirand.com/blog] javascript code easily inside rails views.
|
4
4
|
|
5
|
-
|
5
|
+
It is extremely flexible, all the ruby code is converted to java script code, so you can use all the jqgrid supported features. It is not an abstraction layer from the jqGrid apis, instead, you type the same code you would do to crate the grid using javascript but in Ruby. The code should follow the jqgrid api definition.
|
6
6
|
|
7
|
-
|
7
|
+
For example, to get this java script code:
|
8
8
|
|
9
|
-
|
9
|
+
jQuery("#invoices_list").jqGrid("navGrid", "#invoices_pager", {"search":true,"refresh":false});
|
10
|
+
|
11
|
+
You should type in ruby:
|
10
12
|
|
13
|
+
jqgrid_api 'invoices_list', [:navGrid, '#invoices_pager', {:search => true, :refresh => false}]
|
14
|
+
|
15
|
+
See below for more examples.
|
11
16
|
|
12
17
|
== Installation
|
13
18
|
|
@@ -20,9 +25,18 @@ As a plugin:
|
|
20
25
|
$ rails plugin install git://github.com/Juanmcuello/jqgrid_for_rails.git
|
21
26
|
|
22
27
|
|
28
|
+
== Examples
|
29
|
+
|
30
|
+
There is an example application at:
|
31
|
+
|
32
|
+
https://github.com/Juanmcuello/jqgrid_for_rails_example
|
33
|
+
|
34
|
+
|
23
35
|
== Views
|
24
36
|
|
25
|
-
To generate the grid, you can first create a method in a helper and then call the +
|
37
|
+
To generate the grid, you can first create a method in a helper and then call the +jqgrid_api+ method to generate the java script code. For example, if you have an _invoices_helper.rb_ file, you can define a method there:
|
38
|
+
|
39
|
+
# app/helpers/invoices_helper.rb
|
26
40
|
|
27
41
|
module InvoicesHelper
|
28
42
|
|
@@ -30,66 +44,68 @@ To generate the grid, you can first create a method in a helper and then call th
|
|
30
44
|
|
31
45
|
def invoices_jqgrid
|
32
46
|
|
33
|
-
|
34
|
-
grid_options = {
|
47
|
+
grid = [{
|
35
48
|
:url => '/invoices',
|
36
49
|
:datatype => 'json',
|
37
50
|
:mtype => 'GET',
|
38
51
|
:colNames => ['Inv No','Date'],
|
39
52
|
:colModel => [
|
40
|
-
{ :name => 'invid', :index => 'invid', :width =>
|
41
|
-
{ :name => 'invdate', :index => 'invdate', :width =>
|
53
|
+
{ :name => 'invid', :index => 'invid', :width => 180 },
|
54
|
+
{ :name => 'invdate', :index => 'invdate', :width => 180 },
|
42
55
|
],
|
43
56
|
:pager => '#invoices_pager',
|
44
57
|
:rowNum => 10,
|
45
58
|
:rowList => [10, 20, 30],
|
46
59
|
:caption => 'My first grid',
|
47
60
|
:onSelectRow => "function() { alert('Row selected!');}".to_json_var
|
48
|
-
}
|
61
|
+
}]
|
49
62
|
|
50
|
-
|
63
|
+
jqgrid_api 'invoices_list', grid
|
51
64
|
end
|
52
65
|
end
|
53
66
|
|
54
67
|
Now you can use the helper in the view:
|
55
68
|
|
69
|
+
# app/views/invoices/index.html.erb
|
70
|
+
|
71
|
+
<table id=invoices_list></table>
|
72
|
+
<div id=invoices_pager></div>
|
73
|
+
|
56
74
|
<%= raw(invoices_jqgrid) %>
|
57
75
|
|
76
|
+
|
58
77
|
Or, if you are using Rails 2.3.x :
|
59
78
|
|
60
79
|
<%= invoices_jqgrid %>
|
61
80
|
|
62
81
|
This will result in something like:
|
63
82
|
|
64
|
-
<table id=
|
65
|
-
<div id=
|
83
|
+
<table id=invoices_list></table>
|
84
|
+
<div id=invoices_pager></div>
|
85
|
+
|
66
86
|
<script>
|
67
87
|
jQuery("#invoices_list").jqGrid({
|
68
|
-
"url":
|
69
|
-
"datatype":
|
70
|
-
"mtype":
|
71
|
-
"colNames":
|
72
|
-
"colModel":
|
73
|
-
{"name":"invid",
|
74
|
-
{"name":"invdate",
|
75
|
-
"pager":
|
76
|
-
"rowNum":
|
77
|
-
"rowList":
|
78
|
-
"caption":
|
79
|
-
"onSelectRow":
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
</script
|
88
|
+
"url":"/invoices",
|
89
|
+
"datatype":"json",
|
90
|
+
"mtype":"GET",
|
91
|
+
"colNames":["Inv No","Date"],
|
92
|
+
"colModel":[
|
93
|
+
{"name":"invid","index":"invid","width":180},
|
94
|
+
{"name":"invdate","index":"invdate","width":180}],
|
95
|
+
"pager":"#invoices_pager",
|
96
|
+
"rowNum":10,
|
97
|
+
"rowList":[10,20,30],
|
98
|
+
"caption":"My first grid",
|
99
|
+
"onSelectRow":function() { alert('Row selected!');}
|
100
|
+
});
|
101
|
+
</script>
|
84
102
|
|
85
103
|
Note: resulting code was indented for clarification.
|
86
104
|
|
87
|
-
You can do it better using +content_for+ :
|
88
|
-
|
89
|
-
At the views:
|
105
|
+
You can do it better using +content_for+ in the view:
|
90
106
|
|
91
107
|
<% content_for :head do %>
|
92
|
-
<%= invoices_jqgrid %>
|
108
|
+
<%= raw(invoices_jqgrid) %>
|
93
109
|
<% end %>
|
94
110
|
|
95
111
|
|
@@ -97,19 +113,36 @@ Don't forget to include the jquery and jqgrid javascript and stylesheet files!
|
|
97
113
|
|
98
114
|
== Controllers
|
99
115
|
|
100
|
-
|
116
|
+
There are convenient methods available in the controllers
|
101
117
|
|
102
|
-
|
118
|
+
=== json_for_jqgrid
|
103
119
|
|
104
|
-
|
120
|
+
This method generates the json response for the grid. It takes the records found by the +paginate+ method offered by will_paginate[https://github.com/mislav/will_paginate].
|
105
121
|
|
106
|
-
|
122
|
+
In the controller:
|
107
123
|
|
108
|
-
|
109
|
-
|
124
|
+
# app/controllers/invoices_controller.rb
|
125
|
+
|
126
|
+
class InvoicesController < ApplicationController
|
127
|
+
|
128
|
+
def index
|
129
|
+
@columns = ['invid', 'invdate']
|
130
|
+
@invoices = Invoice.paginate(:page => params[:page], :per_page => params[:rows])
|
131
|
+
|
132
|
+
if request.xhr?
|
133
|
+
render :json => json_for_jqgrid(@invoices, @columns)
|
134
|
+
end
|
110
135
|
end
|
111
136
|
end
|
112
137
|
|
138
|
+
=== order_by_from_params
|
139
|
+
|
140
|
+
This method creates an active record +order+ string using the params sent by the grid.
|
141
|
+
|
142
|
+
@invoices = Invoice.paginate(
|
143
|
+
:page => params[:page],
|
144
|
+
:per_page => params[:rows],
|
145
|
+
:order => order_by_from_params(params))
|
113
146
|
|
114
147
|
== Maintainers
|
115
148
|
|
@@ -1,94 +1,86 @@
|
|
1
1
|
module JqgridsHelper
|
2
2
|
|
3
|
-
# Generates the jqGrid javascript code.
|
4
|
-
#
|
3
|
+
# Generates the jqGrid javascript code. This method returns a jqgrid api function after parsing the
|
4
|
+
# received parameters. If more than one function is specified in the parameters, all the resulting
|
5
|
+
# functions will be chained.
|
5
6
|
#
|
6
|
-
#
|
7
|
-
# If [:html_tags] is +true+, the grid_id will be used when creating the <table> tags.
|
7
|
+
# ==== Parameters
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# * +grid_id+ - This is the id of the html table tag that will contain the grid.
|
10
|
+
# * +*args+ - Each item in the args array will be translated to a jqgrid api function. Each item
|
11
|
+
# should be an array whose elements will be encoded to json to create the jqgrid api function.
|
12
|
+
# All subsequent functions after the first one will be chained.
|
13
|
+
# See the examples for details.
|
10
14
|
#
|
11
|
-
#
|
12
|
-
# If true, <table> tag for the grid, and <div> tag for the table will be generated as well.
|
15
|
+
# ==== Options
|
13
16
|
#
|
14
|
-
#
|
15
|
-
# If true, all the javascript code will be enclosed inside a +jQuery(document).ready+ function
|
17
|
+
# This method accepts an options hash as their last parameter. The accepted options are:
|
16
18
|
#
|
17
|
-
#
|
19
|
+
# [:script_tags]
|
20
|
+
# If false, <script> tags will not be generated. Default true.
|
18
21
|
#
|
19
|
-
#
|
20
|
-
# the javascript code
|
22
|
+
# [:on_document_ready]
|
23
|
+
# If true, all the javascript code will be enclosed inside a +jQuery(document).ready+ function.
|
21
24
|
#
|
22
|
-
#
|
25
|
+
# ==== Examples
|
23
26
|
#
|
24
|
-
#
|
25
|
-
# using the +to_json_var+ method.
|
27
|
+
# A simple call to generate a navigation bar:
|
26
28
|
#
|
27
|
-
#
|
28
|
-
#
|
29
|
+
# jqgrid_api 'invoices_list', [:navGrid, '#invoices_pager', {:search => true, :refresh => false}]
|
30
|
+
# => jQuery("#invoices_list").jqGrid("navGrid", "#invoices_pager", {"search":true,"refresh":false});
|
29
31
|
#
|
30
|
-
#
|
32
|
+
# A more complete example, to create a grid and a pager with a custom button, without the script tags
|
33
|
+
# and with the js code enclosed inside a a +jQuery(document).ready+ function.
|
31
34
|
#
|
32
|
-
#
|
35
|
+
# options = {:on_document_ready => true, :html_tags => false}
|
33
36
|
#
|
34
|
-
#
|
37
|
+
# grid = [{
|
38
|
+
# :url => '/invoices',
|
39
|
+
# :datatype => 'json',
|
40
|
+
# :mtype => 'GET',
|
41
|
+
# :colNames => ['Inv No','Date', 'Amount','Tax','Total','Notes'],
|
42
|
+
# :colModel => [
|
43
|
+
# { :name => 'invid', :index => 'invid', :width => 55 },
|
44
|
+
# { :name => 'invdate', :index => 'invdate', :width => 90 },
|
45
|
+
# { :name => 'amount', :index => 'amount', :width => 80, :align => 'right' },
|
46
|
+
# { :name => 'tax', :index => 'tax', :width => 80, :align => 'right' },
|
47
|
+
# { :name => 'total', :index => 'total', :width => 80, :align => 'right' },
|
48
|
+
# { :name => 'note', :index => 'note', :width => 150, :sortable => false }
|
49
|
+
# ],
|
50
|
+
# :pager => '#invoices_pager',
|
51
|
+
# :rowNum => 10,
|
52
|
+
# :rowList => [10, 20, 30],
|
53
|
+
# :sortname => 'invid',
|
54
|
+
# :sortorder => 'desc',
|
55
|
+
# :viewrecords => true,
|
56
|
+
# :caption => 'My first grid',
|
57
|
+
# :onSelectRow => "function() { alert('Row selected!');}".to_json_var
|
58
|
+
# }]
|
35
59
|
#
|
36
|
-
#
|
60
|
+
# pager = [:navGrid, "#invoices_pager", {:del => true }, {}, {}, {:closeOnEscape => true}]
|
37
61
|
#
|
38
|
-
#
|
39
|
-
# :url => '/invoices',
|
40
|
-
# :datatype => 'json',
|
41
|
-
# :mtype => 'GET',
|
42
|
-
# :colNames => ['Inv No','Date', 'Amount','Tax','Total','Notes'],
|
43
|
-
# :colModel => [
|
44
|
-
# { :name => 'invid', :index => 'invid', :width => 55 },
|
45
|
-
# { :name => 'invdate', :index => 'invdate', :width => 90 },
|
46
|
-
# { :name => 'amount', :index => 'amount', :width => 80, :align => 'right' },
|
47
|
-
# { :name => 'tax', :index => 'tax', :width => 80, :align => 'right' },
|
48
|
-
# { :name => 'total', :index => 'total', :width => 80, :align => 'right' },
|
49
|
-
# { :name => 'note', :index => 'note', :width => 150, :sortable => false }
|
50
|
-
# ],
|
51
|
-
# :pager => '#invoices_pager',
|
52
|
-
# :rowNum => 10,
|
53
|
-
# :rowList => [10, 20, 30],
|
54
|
-
# :sortname => 'invid',
|
55
|
-
# :sortorder => 'desc',
|
56
|
-
# :viewrecords => true,
|
57
|
-
# :caption => 'My first grid',
|
58
|
-
# :onSelectRow => "function() { alert('Row selected!');}".to_json_var
|
59
|
-
# }
|
62
|
+
# pager_button = [:navButtonAdd, "#invoices_pager", {:caption => 'Add', :onClickButton => 'function() {alert("Button!")}'.to_json_var }]
|
60
63
|
#
|
61
|
-
#
|
64
|
+
# jqgrid_api 'invoices_list', grid, pager, pager_button, options
|
62
65
|
#
|
63
|
-
|
64
|
-
|
65
|
-
html_output = []
|
66
|
-
|
67
|
-
# Table
|
68
|
-
html_output << content_tag(:table, nil, :id => grid_id) if options[:html_tags]
|
69
|
-
js_output = "jQuery(\"##{grid_id}\").jqGrid(#{grid_options.to_json});"
|
70
|
-
|
71
|
-
# Pager
|
72
|
-
if grid_options[:pager]
|
66
|
+
#
|
67
|
+
def jqgrid_api div_id, *args
|
73
68
|
|
74
|
-
|
69
|
+
options = args.extract_options!
|
75
70
|
|
76
|
-
|
71
|
+
options[:on_document_ready] ||= false
|
72
|
+
options[:script_tags] = true if options[:script_tags].nil?
|
77
73
|
|
78
|
-
|
79
|
-
|
80
|
-
end
|
74
|
+
result = args.map do |v|
|
75
|
+
".jqGrid(#{v.map { |v| (v || {}).to_json}.join(', ')})"
|
81
76
|
end
|
77
|
+
js = "jQuery(\"##{div_id}\")" + result.join('') + ';'
|
82
78
|
|
83
|
-
wrap_with_document_ready!
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
html_output.join("\n")
|
79
|
+
wrap_with_document_ready!(js) if options[:on_document_ready]
|
80
|
+
wrap_with_script_tags!(js) if options[:script_tags]
|
81
|
+
js
|
88
82
|
end
|
89
83
|
|
90
|
-
private
|
91
|
-
|
92
84
|
# Extracts the pager id from the options hash.
|
93
85
|
#
|
94
86
|
# jQgrid accepts three different formats to set the pager id option.
|
@@ -97,7 +89,7 @@ private
|
|
97
89
|
# 2 - #my_pager_div
|
98
90
|
# 3 - my_pager_div
|
99
91
|
#
|
100
|
-
#
|
92
|
+
# ==== Example
|
101
93
|
#
|
102
94
|
# pager_id_from_options({:pager => "jQuery('#my_pager_id')"})
|
103
95
|
# => 'my_pager_id'
|
@@ -117,12 +109,14 @@ private
|
|
117
109
|
end
|
118
110
|
end
|
119
111
|
|
112
|
+
private
|
113
|
+
|
120
114
|
def wrap_with_document_ready! str
|
121
115
|
str.replace("jQuery(document).ready(function() {#{str}});")
|
122
116
|
end
|
123
117
|
|
124
|
-
def
|
125
|
-
|
118
|
+
def wrap_with_script_tags! str
|
119
|
+
str.replace("<script>\n#{str}\n</script>")
|
126
120
|
end
|
127
121
|
|
128
122
|
end
|
@@ -16,8 +16,8 @@ module JqgridForRails
|
|
16
16
|
# [:id_column]
|
17
17
|
# Says which is the column that should be used as the row id
|
18
18
|
#
|
19
|
-
# :page]
|
20
|
-
# Says the page number
|
19
|
+
# [:page]
|
20
|
+
# Says the page number (Deprecated. The page number is now inferred from +records+)
|
21
21
|
#
|
22
22
|
def json_for_jqgrid records, columns = nil, options = {}
|
23
23
|
|
@@ -26,7 +26,7 @@ module JqgridForRails
|
|
26
26
|
columns ||= records.first.attributes.keys
|
27
27
|
|
28
28
|
options[:id_column] ||= columns.first
|
29
|
-
options[:page] ||=
|
29
|
+
options[:page] ||= records.current_page
|
30
30
|
|
31
31
|
{ :page => options[:page],
|
32
32
|
:total => records.total_pages,
|
@@ -46,7 +46,7 @@ module JqgridForRails
|
|
46
46
|
# => 'updated_at asc'
|
47
47
|
#
|
48
48
|
def order_by_from_params params
|
49
|
-
order_by = params['sidx']
|
49
|
+
order_by = params['sidx'] unless params['sidx'].blank?
|
50
50
|
order_by << " #{params['sord']}" if params['sord'] && order_by
|
51
51
|
order_by
|
52
52
|
end
|
@@ -26,4 +26,9 @@ class ControllerHelpersTest < ActionController::TestCase
|
|
26
26
|
assert_nil @controller.order_by_from_params(params)
|
27
27
|
end
|
28
28
|
|
29
|
+
test "order_by_from with blank sidx" do
|
30
|
+
params = {'sidx' => ''}
|
31
|
+
assert_nil @controller.order_by_from_params(params)
|
32
|
+
end
|
33
|
+
|
29
34
|
end
|
data/test/jqgrids_helper_test.rb
CHANGED
@@ -11,15 +11,13 @@ class JqgridsHelperTest < Test::Unit::TestCase
|
|
11
11
|
@template = MockView.new
|
12
12
|
|
13
13
|
grid_id = 'grid_id'
|
14
|
-
|
15
|
-
grid_options = { :url => "/jqGridModel?model=Wine" }
|
14
|
+
grid_options = [{:url => "/jqGridModel?model=Wine" }]
|
16
15
|
|
17
|
-
expected
|
18
|
-
expected << '<script>' + "\n"
|
16
|
+
expected = '<script>' + "\n"
|
19
17
|
expected << 'jQuery("#'+grid_id+'").jqGrid({"url":"/jqGridModel?model=Wine"});' + "\n"
|
20
18
|
expected << '</script>'
|
21
19
|
|
22
|
-
assert_equal(expected, @template.
|
20
|
+
assert_equal(expected, @template.jqgrid_api(grid_id, grid_options, {:script_tags => true}))
|
23
21
|
|
24
22
|
end
|
25
23
|
|
@@ -27,57 +25,51 @@ class JqgridsHelperTest < Test::Unit::TestCase
|
|
27
25
|
|
28
26
|
@template = MockView.new
|
29
27
|
|
30
|
-
grid_id
|
31
|
-
pager_id
|
32
|
-
grid_options
|
28
|
+
grid_id = 'grid_id'
|
29
|
+
pager_id = 'gridpager'
|
30
|
+
grid_options = [{:pager => "jQuery('##{pager_id}')".to_json_var }]
|
33
31
|
|
34
|
-
options
|
35
|
-
expected
|
36
|
-
assert_equal(expected, @template.
|
32
|
+
options = {:on_document_ready => true }
|
33
|
+
expected = expected_grid(grid_id, pager_id, options)
|
34
|
+
assert_equal(expected, @template.jqgrid_api(grid_id, grid_options, options))
|
37
35
|
|
38
|
-
options
|
39
|
-
expected
|
40
|
-
assert_equal(expected, @template.
|
36
|
+
options = {:on_document_ready => true }
|
37
|
+
expected = expected_grid(grid_id, pager_id, options)
|
38
|
+
assert_equal(expected, @template.jqgrid_api(grid_id, grid_options, options))
|
41
39
|
end
|
42
40
|
|
43
41
|
def expected_grid grid_id, pager_id, options
|
44
|
-
|
45
|
-
|
46
|
-
expected << '<div id="'+pager_id+'"></div>' + "\n" if options[:html_tags]
|
47
|
-
expected << '<script>' + "\n"
|
42
|
+
|
43
|
+
options[:script_tags] ||= true
|
48
44
|
|
49
45
|
js = 'jQuery(document).ready(function() {
|
50
46
|
jQuery("#' + grid_id + '").jqGrid({
|
51
47
|
"pager":jQuery(\'#' + pager_id + '\')
|
52
48
|
});
|
53
49
|
});'
|
54
|
-
|
55
|
-
|
50
|
+
js.gsub!(/\n\s+/, '')
|
51
|
+
js = "<script>\n#{js}\n</script>" if options[:script_tags]
|
52
|
+
js
|
56
53
|
|
57
54
|
end
|
58
55
|
|
59
56
|
def test_jqgrid_nav_options
|
60
57
|
@template = MockView.new
|
61
58
|
|
62
|
-
grid_id
|
63
|
-
pager_id
|
64
|
-
grid_options
|
65
|
-
options
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
expected
|
70
|
-
expected << '<div id="'+pager_id+'"></div>' + "\n"
|
71
|
-
expected << "<script>" + "\n"
|
72
|
-
str = 'jQuery("#'+grid_id+'").jqGrid({"pager":"#'+pager_id+'"});'
|
73
|
-
str << 'jQuery("#'+grid_id+'").jqGrid("navGrid", "#'+pager_id+'", {"del":true}, {}, {}, {"closeOnEscape":true});'
|
74
|
-
expected << "jQuery(document).ready(function() {#{str}});" + "\n"
|
59
|
+
grid_id = 'grid_id'
|
60
|
+
pager_id = 'pager_id'
|
61
|
+
grid_options = {:pager => "##{pager_id}"}
|
62
|
+
options = {:on_document_ready => true, :script_tags => true}
|
63
|
+
|
64
|
+
expected = "<script>" + "\n"
|
65
|
+
str = 'jQuery("#'+grid_id+'").jqGrid({"pager":"#'+pager_id+'"}).jqGrid("navGrid", "#'+pager_id+'", {"del":true}, {}, {}, {"closeOnEscape":true});'
|
66
|
+
expected << "jQuery(document).ready(function() {#{str}});" + "\n"
|
75
67
|
expected << "</script>"
|
76
68
|
|
77
|
-
assert_equal(expected, @template.
|
69
|
+
assert_equal(expected, @template.jqgrid_api(grid_id, [grid_options], [:navGrid, "##{pager_id}", {:del => true }, {}, {}, {:closeOnEscape => true}], options))
|
78
70
|
end
|
79
71
|
|
80
|
-
def
|
72
|
+
def test_pager_id_from_options
|
81
73
|
@template = MockView.new
|
82
74
|
|
83
75
|
assert_equal 'my_pager_div', @template.send(:pager_id_from_options, {:pager => "jQuery('#my_pager_div')"})
|
@@ -86,5 +78,17 @@ class JqgridsHelperTest < Test::Unit::TestCase
|
|
86
78
|
assert_equal 'my_pager_div', @template.send(:pager_id_from_options, {:pager => "my_pager_div"})
|
87
79
|
end
|
88
80
|
|
81
|
+
def test_chained_functions
|
82
|
+
@template = MockView.new
|
83
|
+
div_id = 'my_grid'
|
84
|
+
functions = [
|
85
|
+
[:navButtonAdd, '#pager', { :caption => 'Add'}],
|
86
|
+
[:navSeparatorAdd, '#pager']]
|
87
|
+
|
88
|
+
expected = 'jQuery("#'+div_id+'").jqGrid("navButtonAdd", "#pager", {"caption":"Add"}).jqGrid("navSeparatorAdd", "#pager");'
|
89
|
+
|
90
|
+
assert_equal expected, @template.jqgrid_api(div_id, *functions, {:script_tags => false})
|
91
|
+
|
92
|
+
end
|
89
93
|
|
90
94
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jqgrid_for_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 23
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
6
|
+
- 1
|
7
7
|
- 0
|
8
|
-
- 2
|
9
8
|
- 0
|
10
|
-
version: 0.
|
9
|
+
version: 1.0.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Juan Manuel Cuello
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-30 00:00:00 -03:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
28
|
segments:
|
31
29
|
- 0
|
32
30
|
version: "0"
|
@@ -78,7 +76,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
76
|
requirements:
|
79
77
|
- - ">="
|
80
78
|
- !ruby/object:Gem::Version
|
81
|
-
hash: 3
|
82
79
|
segments:
|
83
80
|
- 0
|
84
81
|
version: "0"
|
@@ -87,7 +84,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
84
|
requirements:
|
88
85
|
- - ">="
|
89
86
|
- !ruby/object:Gem::Version
|
90
|
-
hash: 3
|
91
87
|
segments:
|
92
88
|
- 0
|
93
89
|
version: "0"
|