2016-08-06 20 views
0

django-tables2の列の背景色を設定することはできますか?私の行は2つの異なるオブジェクトデータで構成されているので、それらを簡単に区別するためにuserにする必要があります。列の背景色を設定する

たとえば、列のcssクラスを変更します。

class AdminPairTable(tables.Table): 
    reservation_1_destination_from = tables.TemplateColumn("""{{ record.0.destination_from }}""") 
    reservation_1_destination_to = tables.TemplateColumn("""{{ record.0.destination_to }}""") 
    reservation_1_date_departure = tables.TemplateColumn("""{{record.0.date_departure}}""") 
    reservation_1_time_departure = tables.TemplateColumn("""{{record.0.time_departure}}""") 
    reservation_1_specification = tables.TemplateColumn("""{{record.0.specification}}""") 
    reservation_2_destination_from = tables.TemplateColumn("""{{ record.1.destination_from }}""") 
    reservation_2_destination_to = tables.TemplateColumn("""{{ record.1.destination_to }}""") 
    reservation_2_date_arrival = tables.TemplateColumn("""{{record.1.date_arrival}}""") 
    reservation_2_time_arrival = tables.TemplateColumn("""{{record.1.time_arrival}}""") 
    reservation_2_specification = tables.TemplateColumn("""{{record.1.specification}}""") 
    confirm_pair = tables.TemplateColumn("""<button class="btn btn-success">Zaradiť pár</button>""") 

私の心に来る唯一の方法は、単にJQueryを使用することですが、それは最善の方法ではありません。

答えて

0

列の作成中にcolumn attributesを設定できます。

TemplateColumnを使用して値をレンダリングする理由がわかりません。ちょうどColumnがここでも動作します(もちろんconfirm_pairを除く)。

関連する問題