Primefaces datatable with checkbox selection ONLY

前端 未结 2 1745
眼角桃花
眼角桃花 2020-12-31 16:55

In my project, I use datatable with so that the entries can be multiple selected using the checkboxes.

Ho

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-31 17:05

    Put this in your page, might help stopping selection when you click a row.

    $(document).ready(
        function() {
            $("tr td").click(function(event) {
                if (!$(this).find("div").hasClass("ui-chkbox") 
                      || $(this).find("div").find("div").hasClass("ui-state-disabled")
                      || this == event.target) {
                    event.stopPropagation();
            }
        });
    });
    

    The last condition (this == event.target) is needed when clicking the checkbox column itself outside of the checkbox.

提交回复
热议问题