RailsCasts Pro episodes are now free!

Learn more or hide this

FleXRoR's Profile

GitHub User: FlexRoR

Comments by FleXRoR

Avatar

Solved, by adding the aoColumns to jquery, but sort and search functions don't work

Avatar

Hi ericeche,

I'm looking for apply your solution, but JSON data format changes.
Before record was as:
["December 18, 2013","Forniture",......,"\u003Ca class=\"btn btn-mini\" href=\"/userfeedbacks/11\"\u003EShow\u003C/a\u003E"
Now I have something like that:
[{"created_at":"December 18, 2013","product":"Forniture",....]

I don't understand how to convert it and how I can add some action buttons as in the previous example.

Many thanks

Avatar

I followed the tutorial and I'm able to show data, but I have a couple of issues probably about app/assets/javascripts/products.js.coffee file:

app/assets/javascripts/products.js.coffee
jQuery -> 
  $('#products').dataTable( {
    "sDom": "<'row'<'span3'l><'span9'f>r>t<'row'<'span8'i><'span12'p>>"
    "sPaginationType": "bootstrap",
    "bProcessing": true,
    "bServerSide": true 
    "sAjaxSource": $('#products').data('source')
  } );

1) I don't understand the "sAjaxSource": $('#products').data('source') param. If I try to remove this row nothing changes. Why ?

2) bootstrap layout doesn't work. Below my code:

Table def

app/view/products/index.html.erb
<table id="products" class="datatable table table-striped table-bordered" data-source="<%= products_url(format: "json") %>">```

``` app/assets/javascripts/application.js
//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require bootstrap
//= require twitter/bootstrap
//= require dataTables/jquery.dataTables
//= require dataTables/jquery.dataTables.bootstrap3
//= require products
//= require turbolinks
app/assets/stylesheets/application.css
 *= require_self
 *= require jquery.ui.core
 *= require jquery.ui.theme
 *= require dataTables/jquery.dataTables.bootstrap3
 *= require dataTables/extras/TableTools
 *= require dataTables/extras/TableTools_JUI
 *= require_tree .

Any idea is very appreciated. Thanks