我在用
gem 'jquery-datatables-rails', '3.4.0'
gem 'ajax-datatables-rails'
这个表的我的 CoffeeScript 看起来像
# Datatables
$ ->
table = $('#qr-submissions-table').dataTable
dom: 'C<"clear">lfrtip'
processing: true
serverSide: true
ajax: $('#qr-submissions-table').data('source')
pagingType: 'full_numbers'
columns: [
{data: 'custom_columns'}
{data: 'delivery_number' }
{data: 'qpi_department' }
{data: 'qr_client' }
{data: 'date_submitted'}
{data: 'bay_number' }
{data: 'submitted_by'}
{data: 'delivery_note'}
{data: 'ops' }
]
"order": [[ 3, "desc" ]]
columnDefs: [
{ "orderable": false, "targets": [3, 7, 8]},
{"targets": 1, visible: ($("#delivery_number_show").val() == 'true')},
{"targets": 2, visible: ($("#division_show").val() == 'true')},
{"targets": 3, visible: ($("#client_show").val() == 'true')},
{"targets": 4, visible: ($("#scan_time_show").val() == 'true')},
{"targets": 5, visible: ($("#delivery_location_show").val() == 'true')}
{"targets": 6, visible: ($("#submitted_by_show").val() == 'true')},
{"targets": 7, visible: ($("#delivery_note_show").val() == 'true')},
{"targets": 8, visible: ($("#photo_show").val() == 'true')},
]
这里的自定义列字段是哈希,如'{ "name1" : "value1", "name2" : "value2" }'
.. 我如何将其显示为 coulm 名称和值。name1 和 name2 将是列标题,value1 和 value2 将是对应的行值。每行对于“value1”和“value2”都有不同的值。有没有办法做到这一点?请帮忙?