How to create effective “select all” checkbox in JSF

后端 未结 4 1381
别那么骄傲
别那么骄傲 2020-12-19 19:27

I want to implement select all checkbox into JSF h:datatable. This is the code if the h:datatable:



        
4条回答
  •  佛祖请我去吃肉
    2020-12-19 20:12

    You can do something like this

    
        
             
        
        
    
    

    in your js put this code

        $(window).load(function () {
            $(document).delegate(".checkall", "click", function(event) {
                  $(this).closest("table").find(':checkbox').attr('checked', this.checked);
            });
        });
    

    b.t.w instead of storing in map you can add attribute to your iterated item like this: instead of value="#{SessionsController.selectedIds[item.aSessionID]}" something like this value="#{item.selected}"

    and later on you can iterate over them in the server side and add to list that will be sent to you r delete method...

提交回复
热议问题