About the checkbox selection in datatable
About the checkbox selection in datatable
Dear all,
I am a beginner in using the datatable with Django. I already created the checkbox selection for my datatable successfully, the table only allows checking one row.
My question: Is it possible to set the column default "checked" when the page is rendering based on condition?
I already tried adding {% if ... %} <tr class="selected"> in the target html, it can show the click and fulfill my expectation, but there is a problem that occurs that the table is allowed 2 rows checking. Is any one can help this problem?
Answers
The code I create the checkbox selection
Since you are using the Select extension the best way to select the rows is with the
select()
API. I don't believe access to the select API is available until after the table is initialized. IninitComplete
you can get the rows, based on condition, that need selected then useselect()
. For example:http://live.datatables.net/pajavidu/1/edit
The example doesn't have the
select-checkbox
column but the principal is the same. It uses therow-selector
as a function to fetch the appropriate rows using therows()
API. It uses the resulting rows API to select the rows.Kevin