Sha256: 133397b0de26a5f5922b2495fc7a1b025028054d300da5d57f3b63852ea0c535
Contents?: true
Size: 1.94 KB
Versions: 5
Compression:
Stored size: 1.94 KB
Contents
= JqGridRails Quick Reference == Assocation Values === Accessing assocations @grid.add_column('Bulletin Title', 'bulletin.title') format.json do render :json => grid_response(Bulletin, params, ['bulletin.title']) end === Ordering properly on assocations @grid.add_column('Bulletin Title', 'bulletin.title') format.json do render :json => grid_response(Bulletin, params, { 'bulletin.title' => { :order => 'my_bulletins.title' } }) end == Value Formatting === Providing Ruby based formatting on values format.json do render :json => grid_response(User, params, { :username => nil, 'core_company.name' => { :formatter => proc{|value| value.to_s.upcase} }, :email => nil }) end === Accessing base object value originated from format.json do render :json => grid_response(User, params, { :username => nil, 'core_company.name' => { :formatter => proc{|value,obj| "#{value.to_s.upcase} - #{obj.username}"} }, :email => nil }) end Here, the formatter will receive the current instance of User being processed. === Simple value mapping (applied client side) @grid.add_column('Active', 'active_user', :map_values => {true => 'Active', false => 'Inactive'}) == Events === Ajax call when row is single clicked @grid = JqGridRails::JqGrid.new('users_table', :row_id => :id, :on_cell_select => {:url => :users_path, :remote => true, :args => {:company_id => company.id}} ) === Ajax call when row is double clicked @grid = JqGridRails::JqGrid.new('users_table', :row_id => :id, :ondbl_click_row => {:url => :users_path, :remote => true, :args => {:company_id => company.id}} ) == Add Toolbar Button @grid.link_toolbar_add( :name => 'Edit', :url => :edit_user_path, :remote => true, :class => 'custom-css-class' ) The :remote key will turn AJAX calls off/on. Both AJAX and non-AJAX calls are GET requests
Version data entries
5 entries across 5 versions & 1 rubygems