leikind / wice_grid Goto Github PK
View Code? Open in Web Editor NEWA Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters
Home Page: http://wicegrid.herokuapp.com/
License: MIT License
A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters
Home Page: http://wicegrid.herokuapp.com/
License: MIT License
How to reproduce:
At that point, the grid shows only N records and displays both "show all" and "back to paginated view" links.
I guess that a more appropriate behavior would be either to :
The title explains the problem :-)
Everything seems to be properly installed with one only problem.
That 's the message Message : JS_FRAMEWORK constant is not initialized.
Which causes logically crash of the Application.
Environmet:
Rails 3.0.3
ruby 1.9.2p174
running RVM
installed Gems:
gem 'rails'
gem 'mysql2'
gem 'heroku'
gem 'will_paginate'
gem 'dropbox'
gem 'nifty-generators'
gem 'simple_form'
gem 'jquery-rails'
gem 'wice_grid', '3.0.0.pre1'
Maybe it has got some influence- I get always by starting the Server also the Warning:
/Users/sopira/.rvm/gems/ruby-1.9.2-head@rails3/gems/json_pure-1.4.6/lib/json/common.rb:65: warning: already initialized constant State
/Users/sopira/.rvm/gems/ruby-1.9.2-head@rails3/gems/json_pure-1.4.6/lib/json/common.rb:66: warning: already initialized constant SAFE_STATE_PROTOTYPE
/Users/sopira/.rvm/gems/ruby-1.9.2-head@rails3/gems/json_pure-1.4.6/lib/json/common.rb:67: warning: already initialized constant FAST_STATE_PROTOTYPE
/Users/sopira/.rvm/gems/ruby-1.9.2-head@rails3/gems/json_pure-1.4.6/lib/json/common.rb:74: warning: already initialized constant PRETTY_STATE_PROTOTYPE/Users/sopira/.rvm/gems/ruby-1.9.2-head@rails3/gems/json_pure-1.4.6/lib/json/ext.rb:14: warning: already initialized constant JSON_LOADED
...but this warning is not causing the crash of the applicayion. Only sucks.
thanks for any great idea.
nstant JSON_LOADED
First off, great plugin!
I noticed this error and did some digging. I have Rails 2.3.10 and Ruby 1.8 on Mac OS X Snow Leopard under Mongrel 1.1.5. Apparently due to sporadic garbage collection while doing .CSV export, the temporary file in /tmp is sometimes erased before being sent, causing error in send_file.
According to the documentation of Ruby Tempfile close method, "close(unlink_now=false)
Closes the file. If the optional flag is true, unlinks the file after closing.
If you don‘t explicitly unlink the temporary file, the removal will be delayed until the object is finalized." (http://ruby-doc.org/core/classes/Tempfile.html).
It is obvious from code inspection (in wice_grid_view_helpers.rd:grid_csv) that the object (spreadsheet) is finalized upon return, and the file has not been sent yet, thus, the file can be unlinked / deleted before send_file (or not, depending on Ruby's garbage collector mood).
The define_routes method expects a IActionController::Routing::RouteSet::Mapper object, and controller. name. In rails 3, the ActionController::Routing::RouteSet::Mapper has been deprecated. I'm gettng the exception:
undefined method `create_serialized_query_url' for Class
Seems the routes are not picked by the Rails 3 environment. What change is required to make it work?
Thanks
Rails 3.0 :)
If you replace prototype with jRails, wice_grid will fail to load.
Negation checkbox in text filters should also cause an autoreload
When i use :erb_mode => true, this generate 2 tables.
I use: RAILS 3.0.9 + inherited_resources + Jquery
<%# Wice_Grid %>
<%= include_wice_grid_assets %>
<% grid(@tabela, :show_filters => :always, :erb_mode => true) do |g| %>
<% g.column :column_name => 'Título', :attribute_name => 'titulo' do |tabela| %>
<%= tabela.titulo %>
<% end %>
<% g.column :column_name => 'Agência', :attribute_name => 'agencia' do |tabela| %>
<%= tabela.agencia %>
<% end %>
<% g.column :column_name => 'Conta', :attribute_name => 'conta' do |tabela| %>
<%= tabela.conta %>
<% end %>
<% g.column do |tabela| %>
<%= link_to image_tag('/stylesheets/admin/assets/icons/actions_small/display.png'), tabela, :class => 'tooltip table_icon', :title => 'Visualizar' %>
<%= link_to image_tag('/stylesheets/admin/assets/icons/actions_small/edit.png'), edit_resource_path(tabela), :class => 'tooltip table_icon', :title => 'Editar' %>
<%= link_to image_tag('/stylesheets/admin/assets/icons/actions_small/delete.png'), tabela, :confirm => 'Deseja excluir este item ?', :method => :delete, :class => 'tooltip table_icon', :title => 'Excluir' %>
<% end %>
<% end -%>
Hi!
I would like to bring a filter default. E.g.: Show at the index only the records of current month. What better way ?
I tried a few things in the controller but I had no success.
Thanks a lot
During 'script/generate wice_grid_assets' I got the following (ruby 1.9.1):
vendor/plugins/wice_grid/lib/wice_grid.rb:161: invalid multibyte char (US-ASCII)
.....
And the same for the line 167. The reason is a two-byte chracter 'С' instead of 'C' in the word 'Column'. So, I mean... you know )) \u0421 instead of 43 (ASCII).
Hi!
Hello, I'm trying to use :helper_style => :calendar to style my DATETIME filter and it continues with the helper from rails. In filters DATE jQuery works perfectly.
Currently my index.html.erb is thus:
g.column :column_name => 'Date', :attribute_name => 'date_inicial', :helper_style => :calendar do |ordem_servico|
[(link_to ordem_servico.data_inicial.to_s_br, edit_ordem_servico_path(ordem_servico)),{:class=>"center"}]
end
Can you give some tips how to configure your Jquery helper to my DATETIME Filter ?
Thank u a lot
Example:
class Person < ActiveRecord::Base
belongs_to :company
end
...
@people_grid = initialize_grid(Person, :include => :company, ...)
...
grid(@people_grid) do |g|
g.column(:attribute_name => "name") # will output Person#name
g.column(:attribute_name => "name", :model_class => "Company") # will output Person#name whereas company.name would be expected
end
I have the feeling that this might be a tricky one to solve. It's a totally non-blocking issue but it had to be put on the record. :)
Hi!
How can i to add a last row to grid?
I need to show cumulative values to specifc columns, id this possible with wice grid?
Thanks.
is it possible to select only the date for the DateTime fields through the DatePicker?
JS Calendar for the jQuery version: currently the jQuery version falls down to Rails default date/datetime helpers
for example:
class Post < ActiveRecord::Base
default_scope :conditions => ['state = ?',1]
end
before use wice_grid I found data with this:
Post.send(:with_exclusive_scope) { Post.all }
when I use wice_grid, I must find with this:
initialize_grid(Post)
I have try to this:
Post.send(:with_exclusive_scope) { initialize_grid(Post) }
but it's can not skip Post's default_scope
so, I modify you source code like this:
http://pasite.org/code/279
I add "skip_default_scope" into "options" and default was true, because sometime I used wice_grid in Admin Panel, I want to list all of the records.
Hello Yuri,
I found most users just want to search the exact value instead a range search of an Integer.
So I hacked into the ViewColumnInteger class in view_column.rb, and make a simple javascript addon to line 196
opts1 = {:size => 3, :id => @dom_id, :onkeyup=>"$(#{@dom_id2}).value=$(this).value"}
This will enlighten user experience a bit without losing usefulness of range search abilty.
http://grid.leikind.org/basics5?grid[f][created_at][fr]=2009-10-01 16%3A56&grid[f][created_at][to]=2009-10-31 16%3A56
Is there a way to publish multiple saved_queries_panel so that the records navigation can be done through multiple of them?
Define and document the API of ViewColumn classes to enable users to add their own filters
Sorry, fixed, not wice_grid bug, delete me.
I would like to not only have .csv export, but proper MS-Excel export as well, maybe by using the Ruby Spreadsheet gem in connection with Wice Grid? Thank you for the great Wice Grid, it really rocks, btw!
Running
script/plugin install git://github.com/leikind/wice_grid.git
script/generate wice_grid_assets
in a setup having already wice_grid configured leads to unpredictable results.
A upgrade strategy from previous versions of wice_grid could be helpful. In the meantime, copying wice_grid_assets by hand helps.
2 associations to the same table broken under Rails 2.3.8
Great grid! I really like it.
I have one problem. I can't figure out how to get a polymorphic relationship working, as I have to specify the class name explicitly for any joins.
Could you help? Thanks,
Make sure there's no empty
at http://github.com/leikind/wice_grid/blob/master/lib/helpers/wice_grid_view_helpers.rb#L234Hi,
another problem I have run into: In my new application (Rails 2.3.8), I have enabled export_to_csv. When clicking the export button, there is no file download starting, but the only thing that happens is a new page with only the path to the tmpfile (the csv) rendering in the view, something like:
/var/folders/3N/3NYKFtItHaCuQL6h0KVbkk+++TI/-Tmp-/channels_7068020100831-1170-x3xr6a-0
for my grid named "channels".
I have browsed the code a bit but I cannot see the actual call to send the csv to the browser. If possible, I would like to use apache's x-sendfile for sending the data, but of course getting it to work at all is the priority.
Thank you for looking into this.
I traced to code in generators/wice_grid_jquery.js:read_values_and_form_query_string function, where line
res.push(templates[i] + encodeURIComponent(val));
is called for a checkbox, regardless of its "checked" state. According to HTML spec, checkboxes always have value set, and the submit only posts value when the checkbox is checked. Therefore, the code should not run if the control is a checkbox and it is is not checked.
I am trying to make XML export for index action. Trying this pattern:
def index
@objects_grid = initialize_grid(Users)
unless export_grid_if_requested
respond_to do |format|
format.html
format.xml { render :xml => @objects_grid.current_page_records }
end
end
end
It does not work (as explained nicely in README/Accessing Records Via The WiceGrid Object). I think it is very good use case though. It will allow any export format without a need to mess with wice_grid internals. It would be acceptable to require a partial with grid to return records properly, something like this:
def index
@objects_grid = initialize_grid(Users)
unless export_grid_if_requested
respond_to do |format|
format.html
format.xml { render :xml => @objects_grid.current_page_records(:partial => 'users_grid') }
end
end
end
Any recommendations?
Hello Yuri,
another thing I just ran into: I have a few grids where there are functions as columns, i.e. sum, like this
SELECT ..., SUM(QUANTITY) AS QTY_SUM, ...
Now in the grid, I am not able to sort this column because the column isn't an attribute, but the result of a calculation on an attribute.
MySQL itself has no problems doing an ORDER BY SUM(QUANTITY), but I have no idea how to get Wice Grid to bypass the check if the column name is present. Is there a way? If not, it would be great to have this feature, as it is often needed, and I hereby request it.
Thank you
It appears that the dates entered into the datetime filter are UTC, while the grid shows the datetimes in timezone set by config.time_zone
I fiddled around, and this change to the wice_grid_config.rb seems to be sufficient to make it honor the config setting:
Wice::Defaults::DATETIME_PARSER = lambda{|datetime_string| Time.zone.parse(datetime_string) }
(Using Time.zone.parse instead of DateTime.parse)
Same change looks appropriate for DATE_PARSER.
See if it is possible to add :select to initialize_grid
Hi Yuri,
I would like to be able to pass a group option to the wice grid options because I want to display sums in my resultset. Glancing over the code, I see no particular problem why GROUP BY might be omitted from the available wice grid options. It could be passed along just like conditions or select.
Was there any reason I might be overlooking which led you to not include the GROUP BY option? If not, I'll try to give it a shot.
Thank you
Ben
My data table had 20 million+ rows,I don't need all row total, because I too slow with count(*) from big tables.
I need a param to set toggle show/hide Row Total.
I'm using latest wice_grid with Rails 2.3.8. Error log:
Showing app/views/layouts/application.html.erb where line #10 raised:
uninitialized constant Wice::JsAdaptor
Extracted source (around line #10):
7:
8: <%= stylesheet_link_tag 'formtastic', 'formtastic_changes' %>
9: <%= javascript_include_tag :defaults %>
10: <%= include_wice_grid_assets %>
11: <%= yield :head %>
12:
13:
RAILS_ROOT: /home/max/Rails/cts2
Application Trace | Framework Trace | Full Trace
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:440:in load_missing_constant' /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:in
const_missing'
/home/max/Rails/cts2/vendor/plugins/wice_grid/lib/helpers/wice_grid_misc_view_helpers.rb:62:in include_wice_grid_assets' /home/max/Rails/cts2/app/views/layouts/application.html.erb:10:in
_run_erb_app47views47layouts47application46html46erb'
/home/max/Rails/cts2/app/controllers/records_controller.rb:27:in `index'
I have not found the JsAdaptor declaration in the plugin files.
Thanks god I don't need calendar widget :)
Hi!
I have a virtual column: STATUS that comes from a few terms. I plan to use Detach_with_id.
How can I do this without having to create a new column?
PS.: I stated in the model attr_accessor :status but still have problems.
Browser this message:
WiceGrid: Column 'status' is not found in table 'transacoes'! If 'status' belongs to another table you should declare it in :include or :join when initialising the grid, and specify :model_class in column declaration.
Ability of WiceGrid to reload itself inside its container
Yo!!, 1st I'd like to say thanks for this awesome plugin.
Currently I'm migrating from an older version of the plugin (prototype based) to the latest one using jQuery, almost everything is working fine but I'm having a weird issue while trying to export a csv file, it seems like it's skipping the filter, If I try to export a csv file from the current filtered result, the csv is being generated with the initial records instead of the filtered ones :(. Any Idea why this is happening? This is how one of my actions looks now:
def index @transports = initialize_grid(Transport, :include => [:survey, :pickup, :client, {:dropoff => :company}], :conditions => "surveys.transport_id IS NULL", :enable_export_to_csv => true, :per_page => 30, :csv_file_name => 'transports' ) export_grid_if_requested(:grid => "transports_grid") end
Any help would be appreciated, thanks!
automate editing tasks as bulk deletion. in-place editing, etc
If will_paginate is installed as a gem, e.g. with
jruby -S gem install mislav-will_paginate
the following stacktrace occurs:
$ RAILS_ENV=development jruby script/server
=> Booting WEBrick
=> Rails 2.3.3 application starting on http://0.0.0.0:3000
/home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:443:in load_missing_constant': uninitialized constant WillPaginate (NameError) from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:80:in
const_missing_with_dependencies'
from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:92:in const_missing' from /home/lowry/hobby/buh/vendor/plugins/wice_grid/lib/grid_renderer.rb:9 from /home/lowry/hobby/buh/vendor/plugins/wice_grid/lib/grid_renderer.rb:31:in
require'
from /home/lowry/lib/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require' from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:156:in
require'
from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:521:in new_constants_in' from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:156:in
require'
from /home/lowry/hobby/buh/vendor/plugins/wice_grid/lib/wice_grid.rb:4
from /home/lowry/hobby/buh/vendor/plugins/wice_grid/lib/wice_grid.rb:31:in require' from /home/lowry/lib/jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
require'
from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:156:in require' from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:521:in
new_constants_in'
from /home/lowry/lib/jruby-1.3.1/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:156:in require' from /home/lowry/hobby/buh/vendor/plugins/wice_grid/init.rb:1:in
evaluate_init_rb'
The usual
config.gem "will_paginate", :version => '2.3'
within the Rails::Initializer.run does not work.
Used versions:
$ bundle list rails
/home/timo/.rvm/gems/ruby-1.8.7-p334@lempack/gems/rails-3.0.3
$ bundle list wice_grid
/home/timo/.rvm/gems/ruby-1.8.7-p334@lempack/gems/wice_grid-3.0.0.pre3
Symptoms:
In development mode csv export works like a charm:
rails s
...........
Started GET "/admin/orders?orders[export]=csv" for 127.0.0.1 at Wed May 04 16:52:58 +0200 2011
Processing by Admin::OrdersController#index as HTML
Parameters: {"orders"=>{"export"=>"csv"}}
User Load (0.1ms) SELECT users
.* FROM users
WHERE (users
.id
= 8) LIMIT 1
Role Load (0.1ms) SELECT roles
.* FROM roles
INNER JOIN assignments
ON roles
.id = assignments
.role_id WHERE ((assignments
.user_id = 8))
Order Load (0.1ms) SELECT orders
.* FROM orders
ORDER BY orders
.magento_id
asc
Rendered admin/orders/_orders_grid.html.haml (85.9ms)
Sent file /tmp/orders20110504-15409-u88tk4-0 (0.1ms)
Completed 200 OK in 225ms
-> That's ok, the csv looks good.
Unfortunately the very same request doesnt work in production:
rails s -e production
...................
Started GET "/admin/orders?orders[export]=csv" for 127.0.0.1 at Wed May 04 16:56:17 +0200 2011
Processing by Admin::OrdersController#index as HTML
Parameters: {"orders"=>{"export"=>"csv"}}
Rendered admin/orders/_orders_grid.html.haml (101.6ms)
Sent file /tmp/orders20110504-15877-467q6z-0 (0.1ms)
Completed 200 OK in 105ms
The csv file gets send back, but it's empty. Note that the csv export doesn't work for any of my models in production (all of which are standard AR models).
The problem is apparently that this query isnt executed (among others):
Order Load (0.1ms) SELECT orders. FROM orders ORDER BY orders.magento_id asc*
Seems like an issue with query caching - but this doesn't make sense since the csv export is triggered by a totally separate request (and actually I can see in the logs that this query hasn't been executed ever).
Anything obvious I am missing here?
Automatically populated dropdown filters should be sorted.
I would assume that when the options are provided by the application in array or hash form, it's the responsibility of the app to ensure the ordering, my humble $.02. :)
WiceGrid should optionally support Rails API for localization
CSV import send_file + short living tempfiles + X-Sendfile= problem
send_file in Rails 3 by default uses headers to have the web server send the file. Thus, this is a separate HTTP request and by that time the tempfile in which the CSV data might already have been deleted.
Commenting line config.action_dispatch.x_sendfile_header = "X-Sendfile" forces send_file to send the file the old way, from the same request, but this is not a good solution because it forces all other calls to send_file to do so.
http://www.projectcodegen.com/JQueryDateTimePicker.aspx;
Exists in branch http://github.com/leikind/wice_grid/tree/datetimepicker
Problems:
Hi
Did you think about group actions? One column with checkboxes and buttons like: "Delete selected", "Mark as read", etc
Thanks
Hi!
I'm trying to delete multiple records. Added the g.action_column but can not create the button to send the parameters of the selected records to the controller. Can you help me? Give some idea of how to do?
Thanks so much
Fillipe Norton
create an example application with WiceGrid examples
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.