【问题标题】:How to get selected columns in slickgrid如何在 slickgrid 中获取选定的列
【发布时间】:2019-11-30 11:54:06
【问题描述】:

我正在使用 mleibman/SlickGrid 并且有复选框 (isChecked) 列,

var columns = [                
            { id: "tagID", name: "#", field: "tagID", behavior: "select", cssClass: "cell-selection", width: 40, cannotTriggerInsert: true, resizable: false, selectable: false, excludeFromColumnPicker: true },
            { id: "isChecked", name: "isChecked", field: "isChecked", width: 80, minWidth: 20, maxWidth: 80, cssClass: "slick-cell-check", formatter: Slick.Formatters.Checkbox, editor: Slick.Editors.Checkbox, sortable: true },
            { id: "tagName", name: "tagName", field: "tagName", width: 90, minWidth: 120, cssClass: "cell-title", sortable: true },
            { id: "description", name: "description", field: "description", width: 120, minWidth: 120, cssClass: "cell-title", sortable: true }
        ]; 

如何获取所有选中/选中的行。 我的方法:

function GetCheckedRows() {
    var checkedRows = [];
    for (var i = 0; i < grid.getDataLength(); i++) {
       if (grid.getDataItem(i).isChecked)
            checkedRows.push(grid.getDataItem(i));
    }
    console.log(checkedRows);                
 }

调用 GetCheckedRows 永远不会返回第一个选中的行,第二个选中的行来,并且取消选择不会从 checkedRows 中删除。

【问题讨论】:

    标签: jquery slickgrid


    【解决方案1】:

    首先使用6pac SlickGrid,MLeibman 存储库现在已经死了。

    你是否在该行中缺少一个结束的')'

    if (grid.getDataItem(i).isChecked
    

    或者这只是你发布的内容中的一个错字?

    【讨论】:

    • 这是一个错字,已更正。正在使用 MLeibman/slickgrid 开发旧版 Web 应用程序。我现在正在尝试 6pac slickgrid,我可以看到有一个用于复选框操作的插件。如果该锻炼会更新。
    猜你喜欢
    • 2022-01-09
    • 1970-01-01
    • 2011-12-18
    • 1970-01-01
    • 2011-06-10
    • 2011-12-20
    • 1970-01-01
    • 2021-08-08
    • 1970-01-01
    相关资源
    最近更新 更多