0

選択したデータの 2 つのバージョンを比較するテーブルがあります。このデータには実際には複数のバージョンが保存されているため、テーブルには次のような列があります。

    class ver_compare(tables.Table):
       new_db = tables.CheckBoxColumn()
       data = tables.Column()
       current_rev = tables.Column()
       next_rev = tables.Column()*

各セルとして、choicefield に似た、選択するバージョンのドロップダウン リストが必要な最後のフィールドです。一緒に行くためのアプローチはありますか??

前もって感謝します!!

4

1 に答える 1

3

TemplateColumn を使用できます。ここに、私が考えることができる最も単純なモックアップがあります。もちろん、テンプレートをより便利なものに変更する必要があります。

countries = [
    {'name': 'Australia', 'population': 21, 'tz': 'UTC +10', 'visits': 1},
    {'name': 'Germany', 'population': 81, 'tz': 'UTC +1', 'visits': 2},
    {'name': 'Mexico', 'population': 107, 'tz': 'UTC -6', 'visits': 0},
]

template = """
<select>
<option{% if record.visits = 0%} selected {% endif %}>0
<option{% if record.visits = 1%} selected {% endif %}>1
<option{% if record.visits = 2%} selected {% endif %}>2
</select>
"""

class CountryTable(tables.Table):
    name = tables.Column()
    population = tables.Column()
    tz = tables.Column(verbose_name='time zone')
    visits = tables.TemplateColumn(template)
于 2012-07-04T11:23:22.333 に答える