【问题标题】:Vertical Scroll bar django-tables2垂直滚动条 django-tables2
【发布时间】:2016-11-09 15:23:53
【问题描述】:

谁能告诉我如何在django-tables2 中添加垂直滚动条而不是拥有

Page 1 of 2 Next 25 of 49 vehicles

在表格的底部。

tables.py

'''
Created on 28 Oct 2016

@author: JXA8341
'''
import django_tables2 as tables
from .models import Vehicle

class CheckBoxColumnWithName(tables.CheckBoxColumn):
    @property
    def header(self):
        return self.verbose_name

class VehicleTable(tables.Table):

    update = tables.CheckBoxColumn(accessor="pk", 
                                   attrs = { "th__input":{"onclick": "toggle(this)"}},
                                   orderable=False)

    class Meta:
        model = Vehicle
        fields = ('update', 'vehid')

        # Add class="paleblue" to <table> tag
        attrs = {'class':'paleblue'}

screen.css

 table.paleblue +  ul.pagination {
  font: normal 11px/14px 'Lucida Grande', Verdana, Helvetica, Arial, sans-    serif;
  overflow: scroll;
  margin: 0;
  padding: 10px;
  border: 1px solid #DDD;
  list-style: none;
  }
div.table-container {
     display: inline-block;
     position:relative;
     overflow:auto;
     }

table.html

<div class='vehlist'>
    <script language="JavaScript">
         function toggle(source) {
             checkboxes = document.getElementsByName('update');
             for(var i in checkboxes)
                 checkboxes[i].checked = source.checked;
         }
    </script>
        <form action="/loadlocndb/" method="POST" enctype="multipart/form-data">
            {% csrf_token %}
            {% render_table veh_list %}



            <h4> Location database .csv file</h4>
            {{ form.locndb }}
            <input type="submit" value="Submit" />
        </form>
    </div>

我已经看遍了,但似乎无法得到一个直接的答案,还是有更好的表格模块可以用来显示数组和复选框?

【问题讨论】:

    标签: python html css django django-tables2


    【解决方案1】:

    对于同一条船上的任何人,我都想通了。

    我禁用了分页

    RequestConfig(request, pagination=False).configure(veh_list)

    然后我将表格包裹在 html 模板中的 &lt;div&gt;

    <div style="width: 125px; height: 500px; overflow-y: scroll;">
            {% render_table veh_list %}
    </div>
    

    &lt;div&gt; 然后在整个表格界面中添加了一个滚动条,我个人希望将标题始终保持在顶部,但这是我能想到的最佳解决方案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-14
      • 2014-09-21
      • 1970-01-01
      相关资源
      最近更新 更多