Closed chabgood closed 9 years ago
AjaxDatatablesRails.configure do |config| config.db_adapter = :mysql2 end
@chabgood I made a test with a model that has an integer column, look at this schema:
create_table "orders", force: true do |t|
t.integer "client_id"
t.string "order_number"
t.string "data"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "po_number"
t.float "total", limit: 24
end
I performed a sort on the po_number
column, and this set of images are my results:
Everything works as expected.
Uggh, ok any idea how to troubleshoot why this is not working on my end?
On Tuesday, December 30, 2014, Antonio Antillon notifications@github.com wrote:
@chabgood https://github.com/chabgood I made a test with a model that has an integer column, look at this schema:
create_table "orders", force: true do |t| t.integer "client_id" t.string "order_number" t.string "data" t.datetime "created_at" t.datetime "updated_at" t.integer "po_number" t.float "total", limit: 24 end
I performed a sort on the po_number column, and this set of images are my results:
[image: datatest-1ofn] https://cloud.githubusercontent.com/assets/333671/5576799/8a244d80-8fb8-11e4-99ab-54bac995e8a0.jpg [image: datatest-2ofn] https://cloud.githubusercontent.com/assets/333671/5576798/8a1e754a-8fb8-11e4-9836-9b78ef2b1f8e.jpg [image: datatest-3ofn] https://cloud.githubusercontent.com/assets/333671/5576797/8a1714b2-8fb8-11e4-94ce-03aa4b8d7a87.jpg [image: datatest-4ofn] https://cloud.githubusercontent.com/assets/333671/5576796/8a16162a-8fb8-11e4-92f0-73c46441ed27.jpg [image: datatest-5ofn] https://cloud.githubusercontent.com/assets/333671/5576795/8a0ed964-8fb8-11e4-926b-270ba2f4535e.jpg [image: datatest-6ofn] https://cloud.githubusercontent.com/assets/333671/5576794/8a0e4170-8fb8-11e4-86af-ca38536f7609.jpg [image: datatest-7ofn] https://cloud.githubusercontent.com/assets/333671/5576793/8a0a3472-8fb8-11e4-924c-5ce17957a4e8.jpg [image: datatest-8ofn] https://cloud.githubusercontent.com/assets/333671/5576792/8a05d4ea-8fb8-11e4-8b43-26837affb6e8.jpg
Everything works as expected.
— Reply to this email directly or view it on GitHub https://github.com/antillas21/ajax-datatables-rails/issues/72#issuecomment-68337987 .
"In matters of style, swim with the current; in matters of principle, stand like a rock." Thomas Jefferson
@chabgood: could you post your code here?
JS:
$ -> if $('#po_items_buyers').length $('#po_items_buyers').dataTable processing: true serverSide: true stateSave: true responsive: true jQueryUI: true ajax: $('#po_items_buyers').data('source') pagingType: 'full_numbers' "order": [[ 3, "desc" ]] 'columns': [ { 'sortable': false, 'searchable': false }, { 'sortable': true, 'searchable': true }, { 'sortable': true, 'searchable': true }, { 'sortable': true, 'searchable': true }, { 'sortable': true, 'searchable': true }, { 'sortable': true, 'searchable': true }, { 'sortable': true, 'searchable': true }, { 'sortable': true, 'searchable': true }, { 'sortable': true, 'searchable': true }, { 'sortable': true, 'searchable': true }, { 'sortable': true, 'searchable': true }, { 'sortable': true, 'searchable': true }, { 'sortable': true, 'searchable': true }, { 'sortable': false, 'searchable': false }, ]
class SytelineBuyersDatatable < AjaxDatatablesRails::Base include AjaxDatatablesRails::Extensions::WillPaginate
def_delegators :@view, :link_to, :current_user, :check_box_tag, :h, :number_to_currency, :ontime_syteline_order_path, :late_syteline_order_path, :cancel_syteline_order_path
def cols [ "syteline_orders.vendor_name", "syteline_orders.buyer", "syteline_orders.po_line", "syteline_orders.item_name", "syteline_orders.vendor_item_name", "syteline_orders.item_description", "syteline_orders.qty_ordered", "syteline_orders.qty_received", "syteline_orders.unit_mat_cost", "syteline_orders.u_m", "syteline_orders.due_date", "syteline_orders.status"] end
def sortable_columns
# Example: 'users.email'
@sortable_columns ||= cols
end
def searchable_columns
# Example: 'users.email'
@searchable_columns ||= cols
end
private
def data records.map do |record| [ h(check_box_tag('', record.id, false, :class => 'chk', 'data-order_id' => record.id, 'data-id' => record.vendor_id, 'data-vendor' => record.vendor_name, 'data-poitem' => record.po_line)), record.vendor_name, record.buyer, record.po_id, record.po_line, record.item_name, record.vendor_item_name, record.item_description, record.qty_ordered, record.qty_received, h(number_to_currency(record.try(:unit_mat_cost))), record.u_m, h(record.due_date.try(:strftime, ('%m/%d/%Y'))), record.status, ] end end
def get_raw_records return current_user.syteline_orders.where(:po_id => options[:po_num]) if options[:po_num].present? current_user.syteline_orders.send(options[:scope] || 'pending') end
end
On Tue, Dec 30, 2014 at 3:51 AM, M. Saiqul Haq notifications@github.com wrote:
@chabgood https://github.com/chabgood: could you post your code here?
— Reply to this email directly or view it on GitHub https://github.com/antillas21/ajax-datatables-rails/issues/72#issuecomment-68350535 .
"In matters of style, swim with the current; in matters of principle, stand like a rock." Thomas Jefferson
@chabgood could you please format your code to be easily readable? Please take a look here: https://guides.github.com/features/mastering-markdown/ to know how to format code in github text boxes.
ok, I was replying by email.
On Tue, Dec 30, 2014 at 4:30 PM, Antonio Antillon notifications@github.com wrote:
@chabgood https://github.com/chabgood could you please format your code to be easily readable? Please take a look here: https://guides.github.com/features/mastering-markdown/ to know how to format code in github text boxes.
— Reply to this email directly or view it on GitHub https://github.com/antillas21/ajax-datatables-rails/issues/72#issuecomment-68413927 .
"In matters of style, swim with the current; in matters of principle, stand like a rock." Thomas Jefferson
It does not appear the sort is working, it is hard to tell unless you do 100 records and then you can see the sort is bonked after 59:
It is a integer column.