只有某些行的删除按钮?

时间:2018-01-23 19:52:01

标签: javascript jquery handsontable

我有一个数据的动手,该数据具有指示特定状态的属性(hasShipped,如果需要特定的话)。有没有办法删除"删除行" hasShipped值为true的行中的按钮?

表格定义,如果它很重要:

var hot = new Handsontable(container, {
            data: hotData,
            dataSchema: { Product: null, UOM: "EA", QtyShipped: 0 },
            columns: [
                {
                    data: 'Product',
                    title: "Product",
                    type: "text",
                    readOnly: isShipped 
                },
                {
                    data: 'UOM',
                    title: "UOM",
                    readOnly: true,
                    type: "text"
                },
                {
                    data: 'QtyShipped',
                    title: "Qty<br />Shipped",
                    type: "numeric",
                    readOnly: isShipped 
                }],
            allowInsertRow: true,
            //allowRemoveRow: true, //TODO: Depending on mode and row
            autoWrapCol: true,
            colHeaders: true,
            columnSorting: { column: 0, sortOrder: false },
            contextMenu: ['undo', 'redo', 'row_above', 'row_below', 'remove_row'],
            currentColClassName: 'activeCol',
            currentRowClassName: 'activeRow',
            dropdownMenu: true,
            fixedColumnsLeft: 1,
            outsideClickDeselects: false,
            readOnly: <%= IsWatchList.ToString().ToLower() %>,
            removeRowPlugin: true,
            rowHeaders: true,
            stretchH: "all", //used in conjunction #hot-container styling to make the table take up 100% of parent width
        });

1 个答案:

答案 0 :(得分:1)

鉴于我已经实现了删除行的代码并更改了代码以插入我自己的自定义样式按钮,我知道按钮的注入位置。

感谢MonkeyZues's评论,我查看了我注入删除行按钮的代码,并且根据HasShipped属性的值,能够注入(或不注入)所需的行按钮

 if (jsonObject != "") {
      if (jsonObject.LoadDetails[row]["HasShipped"] == true) {
           div.appendChild(btnNode);
           elem.appendChild(div);
      }
 }