浏览代码

Adds checkbox in head batch column to select all rows

Timothée Barray 14 年之前
父节点
当前提交
661288d81f
共有 1 个文件被更改,包括 12 次插入1 次删除
  1. 12 1
      Resources/views/CRUD/base_list.twig.html

+ 12 - 1
Resources/views/CRUD/base_list.twig.html

@@ -27,7 +27,11 @@ file that was distributed with this source code.
             {% block table_header %}
                 <tr>
                     {% for field_description in fields %}
-                        <th>{{ field_description.name }}</th>
+                        {% if field_description.getOption('code') == '_batch' %}
+                          <th><input type="checkbox" id="list_batch_checkbox" /></th>
+                        {% else %}
+                          <th>{{ field_description.name }}</th>
+                        {% endif %}
                     {% endfor %}
                 </tr>
             {% endblock %}
@@ -62,6 +66,13 @@ file that was distributed with this source code.
                 {% endif %}
             {% endblock %}
         </table>
+        <script type="text/javascript">
+            jQuery(document).ready(function($){
+               $('#list_batch_checkbox').click(function(){
+                   $(this).closest('table').find("td input[type='checkbox']").attr('checked', $(this).is(':checked'));
+               });
+            });
+        </script>
 
         <div>
             <select name="action" >