javascriptjqueryjquery-bootgrid

Trying to select rows in bootgrid


I'm trying to select some rows based in Ids stored in a hidden field. There is a column in the boot grid table called Id, and it has the attribute "data-identifier = true". I'm passing the Ids in an array, and the values are correct (I've checked it in the debugger), but the rows aren't selected. What am I doing wrong? I've tried to pass it as a string array and a number array, and nothing seems to work.

            $('td', row).each(function () {
            if (this.className == $('#hdfSelectedShift').val()) {

                if (this.children[1].value != "") {
                    var employeeIds = [];
             employeeIds = this.children[1].value.split(';').map(Number);
                    $('#tableData').bootgrid("select", employeeIds);
                }
                else {
                    $('#tableData').bootgrid("deselect");
                }
            }
        })

With the function shown above, no rows are selected, even though the array contains the ids. Can you guys please help me? If you need any other code, please ask me.


Solution

  • I Have managed to solve this by deselecting manually using javascript.

        function deselect() { //função para deselecionar a tabela com employees (ajuste para o bootgrid)
            $('#tableData tbody tr').each(function () {
                this.cells[0].children[0].checked = false;
            })
        }