简体   繁体   中英

Get count of primefaces datatable checked checkboxes in javascript

I am pretty new to primefaces.

Currently im using a datatable that has a multiple select checkbox.

My problem is that I have to check if one of the row is selected or not depending on which i have to enable or disable a button on load using javascript.

Current i have used the following code $("tabs:table").getSelectedRowsCount();

tabs: id of tab table: id of the datatable

the getSelectedRowsCount function returns null or is not a function error. I have even tried

$("tabs:table:checks:checked").length;

checks: id of chekcbox

This always returns 0

Would be very helpful if someone can help me out with this.

Thanks.

try

$("#tabs [type=checkbox]:checked").length;

Note: you said tabs: id of tab table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM