我想对如何在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
});