我可以在Rails中将数据表行显示为列吗

时间:2019-07-10 03:48:57

标签: jquery ruby-on-rails gridview datatables

我想对如何在rails的单行中显示3条记录提出一些建议。

示例可以说我有大约100个数据,并且我想每行显示3条记录,例如bootstrap gridview。另外,由于数据量巨大,我想列出前6个数据,并对下6个数据集进行分页。

我用数据表导轨进行了尝试,得到了类似的值

Name: Person 1
Title: Title 1
Location: Location 1

Name: Person 2
Title: Title 2
Location: Location 2

Name: Person 3
Title: Title 3
Location: Location 3

Name: Person 4
Title: Title 4
Location: Location 4

预期的结果是

Name: Person 1          Name: Person 2            Name: Person 3
Title: Title 1          Title: Title 2            Title: Title 3
Location: Location 1    Location: Location 2      Location: Location 3

Name: Person 4
Title: Title 4
Location: Location 4

是否可以通过任何方式更改数据表以将tr显示为列,或者其他任何插件可以帮助我在Ruby on Rails中使用它?

代码:

<div role="tabpanel" class="tab-pane active" id="persons">
  <table class="table table-sm table-hover action-icons" id="person-list" data-source="/users_list/user_listing.json" style='width: 100%;'>
    <thead class="ans-txt">
      <tr>
        <th class="p-2">ID</th>
        <th class="p-2">Details</th>
      </tr>
    </thead>
    <tbody>
    </tbody>
  </table>
</div>

JS:

var person_list = $('#person-list').dataTable({
  "retrieve": true,
  "bLengthChange": false,
  "processing": true,
  "serverSide": true,
  "oLanguage": {
    "sEmptyTable": emptyRowContent
  },      
  "searching": false,
  "ajax": {
    "url": $('#person-list').data('source'),
    "data": function ( d ) {
      d.person_id = personId;
      d.tab_status = "new list";
    }
  },
  "pagingType": "full_numbers",
  "columns": [
    {"data": 'person_details'}
  ],
  "fnDrawCallback": actionForPersonList
});

截屏: https://i.stack.imgur.com/9BdqK.png

0 个答案:

没有答案