ajax-datatables-rails | wrapper around DataTable 's ajax methods | Application Framework library
kandi X-RAY | ajax-datatables-rails Summary
kandi X-RAY | ajax-datatables-rails Summary
DataTables is a nifty jQuery plugin that adds the ability to paginate, sort, and search your html tables. When dealing with large tables (more than a couple of hundred rows) however, we run into performance issues. These can be fixed by using server-side pagination, but this breaks some DataTables functionality. ajax-datatables-rails is a wrapper around DataTables ajax methods that allow synchronization with server-side pagination in a Rails app. It was inspired by this Railscast. I needed to implement a similar solution in a couple projects I was working on, so I extracted a solution into a gem. Joel Quenneville (original author) I needed a good gem to manage a lot of DataTables so I chose this one :) Nicolas Rodriguez (current maintainer). The final goal of this gem is to generate a JSON content that will be given to jQuery DataTables. All the datatable customizations (header, tr, td, css classes, width, height, buttons, etc...) must take place in the javascript definition of the datatable. jQuery DataTables is a very powerful tool with a lot of customizations available. Take the time to read the doc. You'll find a sample project here : Its real world examples. The code is here :
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Sanitize data .
- Returns a Hash representation of the API
- Returns the columns that are connected to this graph
- Returns the searchable columns for this column
- The search for columns
- Gets column data for column data
- Retrieve records for records .
- Get the list of columns for this view .
- Get the view for a given view .
- Returns a set of records for the records .
ajax-datatables-rails Key Features
ajax-datatables-rails Examples and Code Snippets
Community Discussions
Trending Discussions on ajax-datatables-rails
QUESTION
I'm trying to set up server-side DataTables using the ajax-datatables-rails
gem. I've more or less followed the guide, with just a couple minor changes. I can't figure out why I'm running into this error. When navigating to the index page, I receive a 500 error through the AJAX request:
NameError - uninitialized constant AjaxDatatablesRails::Datatable::Column::Search
Any help would be appreciated!
...ANSWER
Answered 2020-Jul-30 at 18:04I figured out a fix. I needed to downgrade from the latest version of the gem, 1.2.0
, to 1.1.0
.
gem 'ajax-datatables-rails', '1.1.0'
QUESTION
I am currently working on a project that has a jquery datatables frontend and am using the ajax-datatables-rails gem to handle the backend. After reviewing the examples they link to and am having a challenge.
I have a datatable and it displays data from a table, lets call it Foo, that has a has_one polymorphic relationship with 3 different tables. My search needs to search on a column in that polymorphic relationship.
...ANSWER
Answered 2020-Apr-08 at 23:16Try this way
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ajax-datatables-rails
with the jquery-datatables gem
by adding the assets manually (in vendor/assets)
with Rails webpacker gem (see here for more infos)
The following examples assume that we are setting up ajax-datatables-rails for an index page of users from a User model, and that we are using Postgresql as our db, because you should be using it. (It also works with other DB, see above). The goal is to render a users table and display : id, first name, last name, email, and bio for each user.
Generate the datatable class
Build the View
Customize the generated Datatables class
Setup the Controller action
Wire up the Javascript
You should always start by the single source of truth, which is your html view.
Set up an html <table> with a <thead> and <tbody>
Add in your table headers if desired
Don't add any rows to the body of the table, DataTables does this automatically
Add a data attribute to the <table> tag with the url of the JSON feed, in our case is the users_path as we're pointing to the UsersController#index action
Set the controller to respond to JSON. Don't forget to make sure the proper route has been added to config/routes.rb. See here if you need to inject params in the UserDatatable. Note : If you have more than 2 datatables in your application, don't forget to read this.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page