select all rows in django_tables2

前端 未结 2 842
遥遥无期
遥遥无期 2020-12-19 08:14

I have tried to select all rows in a table by clicking on the upper check box in a CheckBoxColumn with the following definition:

selection = tables.CheckBoxC         


        
2条回答
  •  -上瘾入骨i
    2020-12-19 08:35

    It is possible to select all checkboxes in a CheckBoxColumn by replacing the input attribute in the header cell:

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

    Then this JavaScript construct in the template file should do the work.

    
    

提交回复
热议问题