Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8075433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:59:04+00:00 2026-06-05T14:59:04+00:00

I have seen this railscast here In that episode Ryan bates show data values.

  • 0

I have seen this railscast here

In that episode Ryan bates show data values. and creates a seperate class for sending the JSON data to the browser. I have done the same. However, instead of all get elements, I would like to add check boxes to my table as well. I have tried many different ways to do the same. However, check boxes donto appear in the datatable columns. What appears is just “true” or “false”values that corresposnd to the checkboxes.

I posted this question on the datatables forum but did not receive an answer that was very useful.

Here is my code for the class on the server side:

class ListingsDatatable
  delegate :params, :h, :link_to, :number_to_currency, to: :@view

  def initialize(view)
    @view = view
  end

  def as_json(options = {})
    {
      sEcho: params[:sEcho].to_i,
      iTotalRecords: Listing.count,
      iTotalDisplayRecords: listings.total_entries,
      aaData: data
    }
  end

private

  def data
    listings.map do |listing|
      [
        h(listing.id),
        link_to(listing.name, listing),
        h(listing.telephone),
        h(listing.fax),

        #This is the code I tried but no checkboxes, instead
        # if the following is included then no data shows in the table
        #check_box_tag('checked?', listing.checked),
        #check_box_tag('collected', listing.collected),
        #check_box_tag('digitized', listing.digitized),
        #check_box_tag('in db?', listing.in_database)

        #if I include the following, 
         #these are boolean values stored in the listings table
        #which generate "true" or "false" in the columns. This works to show the boolean    values. Checkboxes dont.   
        h(listing.keep),
        h(listing.checked),
        h(listing.collected),
        h(listing.digitized),
        h(listing.in_database)
      ]
    end
  end

  def listings
    @listings ||= fetch_listings
  end

  .........

Here is the index.html.erb file

<h3><%= link_to 'Click here to create a new Listing', new_listing_path %></h3>

<table id="listings" class="display" data-source="<%= listings_url(format: "json")%>">
<thead>
  <tr>
  <th>id</th>
  <th>name</th>
  <th>telephone</th>

  <th>Keep this listing?</th>
  <th>Checked</th>
  <th>Collected?</th>
  <th>Digitized?</th>
  <th>in DB?</th>
  </tr>
</thead>

<tbody>

</tbody>
</table>

<br />

Here is the Javascript file listings.js

//#JQuery

//Initialize the datatable
$(document).ready(function()
{
  var oTable = $('#listings').dataTable(
  {
    "sPaginationType":  "full_numbers",
    "bJQueryUI": true,
    "bSortClasses": false,
    "sScrollX": "90%",
    "bScrollCollapse": true,
    "sDom":  '<"top"iflp<"clear">>rt<"bottom"iflp<"clear">>',
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": $('#listings').data('source')
  });
});

Can someone please help me in understanding how can I get the check boxes to show up in those columns

Thanks a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:59:06+00:00Added an answer on June 5, 2026 at 2:59 pm

    So I couldn’t figure a way of making this work with datatables.net. The documentation is vague. however, I realized that this may be by design since they offer datatables jquery as s free option but they have an editable datatable which is a commercial product. Since I couldn’t make this work, I chose to implement my own editable table in 4 hours. I no longer use datatables

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen this question that talks about getting the last part of a
I have seen this statement in many of the documention samples, like here This
I have seen this example: http://jsfiddle.net/UwEe2/306/ that is implemented with scrollleft . Now I
I have seen this post here: jQuery UI autocomplete with item and id but
I have seen this question here, and was wondering if the same method of
I have seen the railscast on self-referential relationships here: http://railscasts.com/episodes/163-self-referential-association I have built upon
I have seen this code in web.xml file <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> I build small
I am implementing Omniauth- Identity and I have seen the Railcast by Ryan Bates
I have seen this on a program that I am tinkering: static const void
I have seen this question a couple of times here in SO but none

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.