Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updrading to jqgrid v3.5 (bis2)

  • Loading branch information...
commit ed49e62dfb1a6f390b6f515c2dd1def23db2bb41 1 parent f325bb1
@ahe authored
Showing with 25 additions and 21 deletions.
  1. +4 −11 app/controllers/users_controller.rb
  2. +21 −10 app/views/users/index.html.erb
View
15 app/controllers/users_controller.rb
@@ -18,10 +18,8 @@ def pets
pets = []
total_entries = 0
end
- respond_to do |format|
- # Fields order is important in the to_jqgrid_json method (in this case : [:id,:name])
- # It must be the same as display order in your datagrid
- format.json { render :json => pets.to_jqgrid_json([:id,:name], params[:page], params[:rows], total_entries) }
+ if request.xhr?
+ render :json => pets.to_jqgrid_json([:id,:name], params[:page], params[:rows], total_entries) and return
end
end
@@ -70,13 +68,8 @@ def index
paginate :page => params[:page], :per_page => params[:rows]
order_by "#{params[:sidx]} #{params[:sord]}"
end
-
- respond_to do |format|
- format.html
- # Fields order is important in the to_jqgrid_json method (in this case : [:id,:name])
- # It must be the same as display order in your datagrid
- format.json { render :json => users.to_jqgrid_json([:id,:pseudo,:firstname,:lastname,:email,:role],
- params[:page], params[:rows], users.total_entries) }
+ if request.xhr?
+ render :json => users.to_jqgrid_json([:id,:pseudo,:firstname,:lastname,:email,:role], params[:page], params[:rows], users.total_entries) and return
end
end
View
31 app/views/users/index.html.erb
@@ -12,7 +12,7 @@
<br/>
<hr/>
<br/>
-<h1>2) Simple DataGrid with selection link/button</h1>
+<h1>2) Simple DataGrid with selection link/button + search disabled</h1>
<script type="text/javascript">
function handleSelection(id) {
@@ -29,14 +29,14 @@
{ :field => "email", :label => "Email" },
{ :field => "role", :label => "Role" }
],
- { :selection_handler => "handleSelection", :height => 300 }
+ { :selection_handler => "handleSelection", :height => 300, :search => false }
) %>
<!-- The ID of this button is important, it must be jqgrid ID (players_2) + _select_button -->
<a href="#" id="players_2_select_button">Get ID of selected row</a>
<br/>
<hr/>
<br/>
-<h1>3) Simple DataGrid with direct selection</h1>
+<h1>3) Simple DataGrid with direct selection + autowidth</h1>
<%= jqgrid("Football Players", "players_3", "/users",
[
{ :field => "id", :label => "ID", :width => 35, :resizable => false },
@@ -46,12 +46,12 @@
{ :field => "email", :label => "Email" },
{ :field => "role", :label => "Role" }
],
- { :selection_handler => "handleSelection", :direct_selection => true }
+ { :selection_handler => "handleSelection", :direct_selection => true, :autowidth => true }
) %>
<br/>
<hr/>
<br/>
-<h1>4) Simple DataGrid with multiple selections</h1>
+<h1>4) Simple DataGrid with multiple selections + row numbers</h1>
<%= jqgrid("Football Players", "players_4", "/users",
[
{ :field => "id", :label => "ID", :width => 35, :resizable => false },
@@ -61,7 +61,7 @@
{ :field => "email", :label => "Email" },
{ :field => "role", :label => "Role" }
],
- { :selection_handler => "handleSelection", :multi_selection => true }
+ { :selection_handler => "handleSelection", :multi_selection => true, :rownumbers => true }
) %>
<!-- The ID of this button is important, it must be jqgrid ID (players_4) + _select_button -->
<a href="#" id="players_4_select_button">Get IDs of selected rows</a>
@@ -224,11 +224,11 @@ function pickDates(id) {
<hr/>
<br/>
<script type="text/javascript">
-
+
function handleSubSelection(id) {
alert('ID selected : ' + id);
}
-
+
</script>
<h1>12) Subgrids with selection</h1>
<%= jqgrid("Football Players", "players_11", "/users",
@@ -250,6 +250,17 @@ function pickDates(id) {
}
) %>
<br/>
+<hr/>
<br/>
-<br/>
-<br/>
+<h1>13) Form Improvements</h1>
+<%= jqgrid("Football Players", "players_13", "/users",
+ [
+ { :field => "id", :label => "ID", :width => 35, :resizable => false },
+ { :field => "pseudo", :label => "Pseudo", :editable => true, :formoptions => { :rowpos => 1, :elmprefix => "(*)&nbsp;&nbsp" }, :editoptions => { :size => 22 }, :editrules => { :required => true } },
+ { :field => "firstname", :label => "Firstname", :editable => true, :formoptions => { :rowpos => 4, :label => "A label" }, :editoptions => { :size => 22 } },
+ { :field => "lastname", :label => "Lastname", :editable => true, :formoptions => { :rowpos => 5 }, :editoptions => { :size => 22 } },
+ { :field => "email", :label => "Email", :editable => true, :formoptions => { :rowpos => 3 }, :editoptions => { :size => 22 } },
+ { :field => "role", :label => "Role", :editable => true, :stype => "select", :edittype => "select", :formoptions => { :rowpos => 2 }, :editoptions => { :value => [["admin","admin"], ["player", "player"], ["defender","defender"]], :size => 22 } }
+ ],
+ { :add => true, :edit => true, :inline_edit => true, :delete => true, :edit_url => "/users/post_data" }
+) %>
Please sign in to comment.
Something went wrong with that request. Please try again.