How to find checked rows in YUI DataTable?

I am using a YUI DataTable with a checkbox column like this:

var myColumnDefs = [
    {key:"check", label:'', formatter:"checkbox"},                               
    {other columns...}
];

How can I iterate over all checked rows?

UPDATE:

Here is my current job:

function getCheckedIds() {
    var records = yuiDataTable.getRecordSet().getRecords();
    var ids = '';

    for (i=0; i < records.length; i++) {
        var checked = false;
        if (records[i] != undefined)
        {
            checked = $('#' + records[i].getId() + ' td div.yui-dt-liner input.yui-dt-checkbox').attr('checked');
            if (checked) {
                if (ids != '') {
                    ids += ',';
                }
                ids += records[i].getData("item.id");
            }
        }
    }
    return ids;    
}
+3
source share
1 answer

A better approach would be to subscribe to checkboxClickEvent from Datatable, then when the checkbox is checked (or not selected), programmatically mark the row as selected using the selectRow / unselectRow method for Datatable. If you do, it looks better in the user interface (rows are highlighted), and getting selected rows is easy using the getSelectedRows method for Datatable.

+2
source

Source: https://habr.com/ru/post/1749561/


All Articles