【问题标题】:Trying to select rows in bootgrid尝试在 bootgrid 中选择行
【发布时间】:2019-08-06 13:02:01
【问题描述】:

我正在尝试根据存储在隐藏字段中的 ID 选择一些行。引导网格表中有一个名为 Id 的列,它具有属性“data-identifier = true”。我在数组中传递 Id,并且值是正确的(我已经在调试器中检查过),但没有选择行。我究竟做错了什么?我尝试将它作为字符串数组和数字数组传递,但似乎没有任何效果。

            $('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");
                }
            }
        })

使用上面显示的函数,即使数组包含 id,也不会选择任何行。你们能帮帮我吗?如果您需要任何其他代码,请询问我。

【问题讨论】:

  • 你确定选择器$('td', row) 是真的吗?如果您想选择多个选择器,请这样做$('td, row')
  • 是的。 Row 是一个对象,是表中的一行,我想在其中找到特定的 td (抱歉没有指出)。顺便说一句,该函数没有给我任何错误,我可以在 employeeIds 变量中看到更正的 Id。

标签: javascript jquery jquery-bootgrid


【解决方案1】:

我已经设法通过使用 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;
        })
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多