ruby on rails - I want to add check boxes to my jQuery datatables plug in -
i have seen railscast here
in episode ryan bates show data values. , creates seperate class sending json data browser. have done same. however, instead of elements, add check boxes table well. have tried many different ways same. however, check boxes donto appear in datatable columns. appears "true" or "false"values corresposnd checkboxes.
i posted question on datatables forum did not receive answer useful.
here code class on 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 |listing| [ h(listing.id), link_to(listing.name, listing), h(listing.telephone), h(listing.fax), #this code tried no checkboxes, instead # if following included no data shows in 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 include following, #these boolean values stored in listings table #which generate "true" or "false" in columns. works show 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 index.html.erb file
<h3><%= link_to 'click here create 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 listing?</th> <th>checked</th> <th>collected?</th> <th>digitized?</th> <th>in db?</th> </tr> </thead> <tbody> </tbody> </table> <br />
here javascript file listings.js
//#jquery //initialize 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 please me in understanding how can check boxes show in columns
thanks lot.
so couldn't figure way of making work datatables.net. documentation vague. however, realized may design since offer datatables jquery s free option have editable datatable commercial product. since couldn't make work, chose implement own editable table in 4 hours. no longer use datatables
Comments
Post a Comment