Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for subgrids

  • Loading branch information...
commit ee28bbdb9bbbdc53eff721a0ab368fbb5cb24c5e 1 parent 695b97f
@ahe authored
Showing with 86 additions and 4,322 deletions.
  1. +27 −1 app/views/users/index.html.erb
  2. +0 −4,310 log/development.log
  3. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/MIT-LICENSE
  4. +1 −1  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/README
  5. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/Rakefile
  6. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/init.rb
  7. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/install.rb
  8. +58 −10 vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/lib/2dc_jqgrid.rb
  9. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/search.png
  10. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/ui-bg_flat_0_aaaaaa_40x100.png
  11. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/ui-bg_flat_55_fbec88_40x100.png
  12. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/ui-bg_glass_75_d0e5f5_1x400.png
  13. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/ui-bg_glass_85_dfeffc_1x400.png
  14. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/ui-bg_glass_95_fef1ec_1x400.png
  15. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/ui-bg_gloss-wave_55_5c9ccc_500x100.png
  16. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/ui-bg_inset-hard_100_f5f8f9_1x100.png
  17. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/ui-bg_inset-hard_100_fcfdfd_1x100.png
  18. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/ui-icons_217bc0_256x240.png
  19. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/ui-icons_2e83ff_256x240.png
  20. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/ui-icons_469bdd_256x240.png
  21. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/ui-icons_6da8d5_256x240.png
  22. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/ui-icons_cd0a0a_256x240.png
  23. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/ui-icons_d8e7f3_256x240.png
  24. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/images/jqgrid/ui-icons_f9bd01_256x240.png
  25. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/JsonXml.js
  26. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/grid.base.js
  27. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/grid.celledit.js
  28. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/grid.common.js
  29. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/grid.custom.js
  30. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/grid.formedit.js
  31. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/grid.import.js
  32. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/grid.inlinedit.js
  33. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/grid.locale-en.js
  34. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/grid.postext.js
  35. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/grid.setcolumns.js
  36. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/grid.subgrid.js
  37. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/grid.tbltogrid.js
  38. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/grid.treegrid.js
  39. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/jqDnR.js
  40. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/jqModal.js
  41. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/jquery.fmatter.js
  42. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/jquery.jqGrid.js
  43. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/jquery.js
  44. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/jquery.layout.js
  45. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/jquery.tablednd.js
  46. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/jquery.ui.all.js
  47. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/json2.js
  48. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/javascripts/jqgrid/tablednd.js
  49. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/stylesheets/jqgrid/ui.all.css
  50. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/public/stylesheets/jqgrid/ui.jqgrid.css
  51. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/tasks/2dc_jqgrid_tasks.rake
  52. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/test/2dc_jqgrid_test.rb
  53. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/test/test_helper.rb
  54. 0  vendor/plugins/{2dcjqgrid → 2dc_jqgrid}/uninstall.rb
View
28 app/views/users/index.html.erb
@@ -134,4 +134,30 @@
:editoptions => { :value => [["admin","admin"], ["player", "player"], ["defender","defender"]] } }
],
{ :add => true, :edit => true, :inline_edit => true, :delete => true, :edit_url => "/users/post_data" }
-) %>
+) %>
+<br/>
+<hr/>
+<br/>
+<h1>Subgrids</h1>
+<%= jqgrid("Football Players", "players_9", "/users",
+ [
+ { :field => "id", :label => "ID", :width => 35, :resizable => false },
+ { :field => "pseudo", :label => "Pseudo" },
+ { :field => "firstname", :label => "Firstname" },
+ { :field => "lastname", :label => "Lastname" },
+ { :field => "email", :label => "Email" },
+ { :field => "role", :label => "Role" }
+ ],
+ {
+ :subgrid => { :url => "/users/pets", :search => true,
+ :columns => [
+ { :field => "id", :label => "ID", :width => 35, :resizable => false },
+ { :field => "name", :label => "Name" }
+ ]
+ }
+ }
+) %>
+<br/>
+<br/>
+<br/>
+<br/>
View
4,310 log/development.log
0 additions, 4,310 deletions not shown
View
0  vendor/plugins/2dcjqgrid/MIT-LICENSE → vendor/plugins/2dc_jqgrid/MIT-LICENSE
File renamed without changes
View
2  vendor/plugins/2dcjqgrid/README → vendor/plugins/2dc_jqgrid/README
@@ -15,7 +15,7 @@ Following features are supported :
- Themes
- And more ...
-Documentation & live demo are available at http://www.2dconcept.com/jquery-grid-rails-plugin.html
+Documentation & live demo are available at http://www.2dconcept.com/jquery-grid-rails-plugin
Enjoy!
View
0  vendor/plugins/2dcjqgrid/Rakefile → vendor/plugins/2dc_jqgrid/Rakefile
File renamed without changes
View
0  vendor/plugins/2dcjqgrid/init.rb → vendor/plugins/2dc_jqgrid/init.rb
File renamed without changes
View
0  vendor/plugins/2dcjqgrid/install.rb → vendor/plugins/2dc_jqgrid/install.rb
File renamed without changes
View
68 vendor/plugins/2dcjqgrid/lib/2dc_jqgrid.rb → vendor/plugins/2dc_jqgrid/lib/2dc_jqgrid.rb
@@ -28,14 +28,7 @@ def jqgrid(title, id, action, columns = {}, options = {})
edit_button = (options[:edit] == true && options[:inline_edit] == "false") ? "true" : "false"
# Generate columns data
- col_names = "[" # Labels
- col_model = "[" # Options
- columns.each do |c|
- col_names << "'#{c[:label]}',"
- col_model << "{name:'#{c[:field]}', index:'#{c[:field]}'#{get_attributes(c)}},"
- end
- col_names.chop! << "]"
- col_model.chop! << "]"
+ col_names, col_model = gen_columns(columns)
# Enable multi-selection (checkboxes)
multiselect = ""
@@ -45,6 +38,7 @@ def jqgrid(title, id, action, columns = {}, options = {})
jQuery("##{id}_select_button").click( function() {
var s; s = jQuery("##{id}").getGridParam('selarrrow');
#{options[:selection_handler]}(s);
+ return false;
});/
end
@@ -82,7 +76,8 @@ def jqgrid(title, id, action, columns = {}, options = {})
#{options[:selection_handler]}(id);
} else {
alert("Please select a row");
- }
+ }
+ return false;
});/
end
@@ -122,6 +117,42 @@ def jqgrid(title, id, action, columns = {}, options = {})
}
},/
end
+
+ # Enable subgrids
+ subgrid = ""
+ subgrid_enabled = "subGrid:false,"
+ if options[:subgrid]
+ subgrid_enabled = "subGrid:true,"
+ options[:subgrid][:rows_per_page] = "10" if options[:subgrid][:rows_per_page].blank?
+ options[:subgrid][:sort_column] = "id" if options[:subgrid][:sort_column].blank?
+ options[:subgrid][:sort_order] = "asc" if options[:subgrid][:sort_order].blank?
+ subgrid_search = (options[:subgrid][:search].blank?) ? "false" : options[:subgrid][:search]
+ sub_col_names, sub_col_model = gen_columns(options[:subgrid][:columns])
+
+ subgrid = %Q(
+ subGridRowExpanded: function(subgrid_id, row_id) {
+ var subgrid_table_id, pager_id;
+ subgrid_table_id = subgrid_id+"_t";
+ pager_id = "p_"+subgrid_table_id;
+ $("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>");
+ jQuery("#"+subgrid_table_id).jqGrid({
+ url:"#{options[:subgrid][:url]}?q=2&id="+row_id,
+ datatype: "json",
+ colNames: #{sub_col_names},
+ colModel: #{sub_col_model},
+ rowNum:#{options[:subgrid][:rows_per_page]},
+ pager: pager_id,
+ imgpath: '/images/themes/lightness/images',
+ sortname: '#{options[:subgrid][:sort_column]}',
+ sortorder: '#{options[:subgrid][:sort_order]}',
+ height: '100%'
+ })
+ .navGrid("#"+pager_id,{edit:false,add:false,del:false,search:#{subgrid_search}})
+ },
+ subGridRowColapsed: function(subgrid_id, row_id) {
+ },
+ )
+ end
# Generate required Javascript & html to create the jqgrid
%Q(
@@ -148,6 +179,8 @@ def jqgrid(title, id, action, columns = {}, options = {})
#{grid_loaded}
#{direct_link}
#{editable}
+ #{subgrid_enabled}
+ #{subgrid}
caption: "#{title}"
});
jQuery("#t_#{id}").height(25).hide().filterGrid("#{id}",{gridModel:true,gridToolbar:true});
@@ -171,6 +204,19 @@ def jqgrid(title, id, action, columns = {}, options = {})
end
private
+
+ def gen_columns(columns)
+ # Generate columns data
+ col_names = "[" # Labels
+ col_model = "[" # Options
+ columns.each do |c|
+ col_names << "'#{c[:label]}',"
+ col_model << "{name:'#{c[:field]}', index:'#{c[:field]}'#{get_attributes(c)}},"
+ end
+ col_names.chop! << "]"
+ col_model.chop! << "]"
+ [col_names, col_model]
+ end
# Generate a list of attributes for related column (align:'right', sortable:true, resizable:false, ...)
def get_attributes(column)
@@ -222,7 +268,9 @@ def to_jqgrid_json(attributes, current_page, per_page, total)
json << %Q({"id":"#{elem.id}","cell":[)
couples = elem.attributes.symbolize_keys
attributes.each do |atr|
- json << %Q("#{couples[atr]}",)
+ value = couples[atr]
+ value = elem.try(atr) if value.blank?
+ json << %Q("#{value}",)
end
json.chop! << "]},"
end
View
0  ...2dcjqgrid/public/images/jqgrid/search.png → ...dc_jqgrid/public/images/jqgrid/search.png
File renamed without changes
View
0  ...ges/jqgrid/ui-bg_flat_0_aaaaaa_40x100.png → ...ges/jqgrid/ui-bg_flat_0_aaaaaa_40x100.png
File renamed without changes
View
0  ...es/jqgrid/ui-bg_flat_55_fbec88_40x100.png → ...es/jqgrid/ui-bg_flat_55_fbec88_40x100.png
File renamed without changes
View
0  ...es/jqgrid/ui-bg_glass_75_d0e5f5_1x400.png → ...es/jqgrid/ui-bg_glass_75_d0e5f5_1x400.png
File renamed without changes
View
0  ...es/jqgrid/ui-bg_glass_85_dfeffc_1x400.png → ...es/jqgrid/ui-bg_glass_85_dfeffc_1x400.png
File renamed without changes
View
0  ...es/jqgrid/ui-bg_glass_95_fef1ec_1x400.png → ...es/jqgrid/ui-bg_glass_95_fef1ec_1x400.png
File renamed without changes
View
0  ...id/ui-bg_gloss-wave_55_5c9ccc_500x100.png → ...id/ui-bg_gloss-wave_55_5c9ccc_500x100.png
File renamed without changes
View
0  ...rid/ui-bg_inset-hard_100_f5f8f9_1x100.png → ...rid/ui-bg_inset-hard_100_f5f8f9_1x100.png
File renamed without changes
View
0  ...rid/ui-bg_inset-hard_100_fcfdfd_1x100.png → ...rid/ui-bg_inset-hard_100_fcfdfd_1x100.png
File renamed without changes
View
0  ...images/jqgrid/ui-icons_217bc0_256x240.png → ...images/jqgrid/ui-icons_217bc0_256x240.png
File renamed without changes
View
0  ...images/jqgrid/ui-icons_2e83ff_256x240.png → ...images/jqgrid/ui-icons_2e83ff_256x240.png
File renamed without changes
View
0  ...images/jqgrid/ui-icons_469bdd_256x240.png → ...images/jqgrid/ui-icons_469bdd_256x240.png
File renamed without changes
View
0  ...images/jqgrid/ui-icons_6da8d5_256x240.png → ...images/jqgrid/ui-icons_6da8d5_256x240.png
File renamed without changes
View
0  ...images/jqgrid/ui-icons_cd0a0a_256x240.png → ...images/jqgrid/ui-icons_cd0a0a_256x240.png
File renamed without changes
View
0  ...images/jqgrid/ui-icons_d8e7f3_256x240.png → ...images/jqgrid/ui-icons_d8e7f3_256x240.png
File renamed without changes
View
0  ...images/jqgrid/ui-icons_f9bd01_256x240.png → ...images/jqgrid/ui-icons_f9bd01_256x240.png
File renamed without changes
View
0  ...grid/public/javascripts/jqgrid/JsonXml.js → ...grid/public/javascripts/jqgrid/JsonXml.js
File renamed without changes
View
0  ...id/public/javascripts/jqgrid/grid.base.js → ...id/public/javascripts/jqgrid/grid.base.js
File renamed without changes
View
0  ...ublic/javascripts/jqgrid/grid.celledit.js → ...ublic/javascripts/jqgrid/grid.celledit.js
File renamed without changes
View
0  .../public/javascripts/jqgrid/grid.common.js → .../public/javascripts/jqgrid/grid.common.js
File renamed without changes
View
0  .../public/javascripts/jqgrid/grid.custom.js → .../public/javascripts/jqgrid/grid.custom.js
File renamed without changes
View
0  ...ublic/javascripts/jqgrid/grid.formedit.js → ...ublic/javascripts/jqgrid/grid.formedit.js
File renamed without changes
View
0  .../public/javascripts/jqgrid/grid.import.js → .../public/javascripts/jqgrid/grid.import.js
File renamed without changes
View
0  ...blic/javascripts/jqgrid/grid.inlinedit.js → ...blic/javascripts/jqgrid/grid.inlinedit.js
File renamed without changes
View
0  ...blic/javascripts/jqgrid/grid.locale-en.js → ...blic/javascripts/jqgrid/grid.locale-en.js
File renamed without changes
View
0  ...public/javascripts/jqgrid/grid.postext.js → ...public/javascripts/jqgrid/grid.postext.js
File renamed without changes
View
0  ...lic/javascripts/jqgrid/grid.setcolumns.js → ...lic/javascripts/jqgrid/grid.setcolumns.js
File renamed without changes
View
0  ...public/javascripts/jqgrid/grid.subgrid.js → ...public/javascripts/jqgrid/grid.subgrid.js
File renamed without changes
View
0  ...blic/javascripts/jqgrid/grid.tbltogrid.js → ...blic/javascripts/jqgrid/grid.tbltogrid.js
File renamed without changes
View
0  ...ublic/javascripts/jqgrid/grid.treegrid.js → ...ublic/javascripts/jqgrid/grid.treegrid.js
File renamed without changes
View
0  ...jqgrid/public/javascripts/jqgrid/jqDnR.js → ...jqgrid/public/javascripts/jqgrid/jqDnR.js
File renamed without changes
View
0  ...grid/public/javascripts/jqgrid/jqModal.js → ...grid/public/javascripts/jqgrid/jqModal.js
File renamed without changes
View
0  ...blic/javascripts/jqgrid/jquery.fmatter.js → ...blic/javascripts/jqgrid/jquery.fmatter.js
File renamed without changes
View
0  ...ublic/javascripts/jqgrid/jquery.jqGrid.js → ...ublic/javascripts/jqgrid/jquery.jqGrid.js
File renamed without changes
View
0  ...qgrid/public/javascripts/jqgrid/jquery.js → ...qgrid/public/javascripts/jqgrid/jquery.js
File renamed without changes
View
0  ...ublic/javascripts/jqgrid/jquery.layout.js → ...ublic/javascripts/jqgrid/jquery.layout.js
File renamed without changes
View
0  ...lic/javascripts/jqgrid/jquery.tablednd.js → ...lic/javascripts/jqgrid/jquery.tablednd.js
File renamed without changes
View
0  ...ublic/javascripts/jqgrid/jquery.ui.all.js → ...ublic/javascripts/jqgrid/jquery.ui.all.js
File renamed without changes
View
0  ...jqgrid/public/javascripts/jqgrid/json2.js → ...jqgrid/public/javascripts/jqgrid/json2.js
File renamed without changes
View
0  ...rid/public/javascripts/jqgrid/tablednd.js → ...rid/public/javascripts/jqgrid/tablednd.js
File renamed without changes
View
0  ...grid/public/stylesheets/jqgrid/ui.all.css → ...grid/public/stylesheets/jqgrid/ui.all.css
File renamed without changes
View
0  ...d/public/stylesheets/jqgrid/ui.jqgrid.css → ...d/public/stylesheets/jqgrid/ui.jqgrid.css
File renamed without changes
View
0  ...ins/2dcjqgrid/tasks/2dc_jqgrid_tasks.rake → ...ns/2dc_jqgrid/tasks/2dc_jqgrid_tasks.rake
File renamed without changes
View
0  ...plugins/2dcjqgrid/test/2dc_jqgrid_test.rb → ...lugins/2dc_jqgrid/test/2dc_jqgrid_test.rb
File renamed without changes
View
0  vendor/plugins/2dcjqgrid/test/test_helper.rb → ...or/plugins/2dc_jqgrid/test/test_helper.rb
File renamed without changes
View
0  vendor/plugins/2dcjqgrid/uninstall.rb → vendor/plugins/2dc_jqgrid/uninstall.rb
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.