如何隐藏表格中的“全选"-复选框? [英] How to hide "Select All"-CheckBox from Table?

查看:46
本文介绍了如何隐藏表格中的“全选"-复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除允许从表 (sap.m.Table) 中选择所有项目的复选框.

I want to remove the check box which enables selecting all items from the table (sap.m.Table).

我试过了:

var oTable = this.byId('MyTableId');
oTable._getSelectAllCheckbox().setVisible(false);

它对我不起作用.有没有办法在 XML 中将其设置为 false ?我知道我可以使用 CSS,但我只想在没有其他解决方案的情况下使用 CSS.

It didn't work for me. Is there a way to set it false in XML? I know I can use CSS but I want to use CSS only if there is no other solution.

推荐答案

sap.m.Table

(又名.响应式表格)

目前,没有公开记录的 API 来启用/禁用在 sap.m.Table 上显示全选"-CheckBox.这种情况下的最佳实践是扩展控制并相应地切换 bPreventMassSelection 状态.

Currently, there is no publicly documented API to enable/disable showing the "Select All"-CheckBox on sap.m.Table. Best practice in this case is to extend the control and to switch the bPreventMassSelection state accordingly.

这是示例的片段:https://embed.plnkr.co/pnpdRK7d7CxZXZ8s

Here is a snippet from the sample: https://embed.plnkr.co/pnpdRK7d7CxZXZ8s

sap.ui.define([
  "sap/m/Table",
  "sap/m/TableRenderer",
], function(Table, TableRenderer) {
  "use strict";

  return Table.extend("demo.control.MyResponsiveTable", {
    metadata: {
      properties: {
        showSelectAll: {
          type: "boolean",
          bindable: true,
        },
      },
    },

    setShowSelectAll: function(bValue) {
      this.bPreventMassSelection = !bValue;
      this.setProperty("showSelectAll", bValue);
      return this;
    },

    renderer: TableRenderer,
  });
});

<demo:MyResponsiveTable xmlns:demo="demo.control"
  showSelectAll="{/showSelectAll}"
  mode="MultiSelect">

_getSelectAllCheckbox 相比,上述方法应该受到青睐,因为:

Compared to _getSelectAllCheckbox, the above approach should be favored since:

  • _getSelectAllCheckbox 是一种私有方法.
    • 私有方法不应在控件定义之外使用.
    • 依赖私有方法和/或操纵内部控件(CheckBox)在未来的 UI5 版本中破坏应用.
    • _getSelectAllCheckbox is a private method.
      • Private methods are not intended to be used outside of the control definition.
      • Relying on private methods and/or manipulating the internal control (CheckBox) will break the app in future UI5 releases.

      (又名.网格表)

      如果有人正在寻找解决方案但使用 sap.ui.table.Table,请设置 enableSelectAll 属性为 false:

      In case someone was looking for the solution but with sap.ui.table.Table, set the enableSelectAll property to false:

      <table:Table xmlns:table="sap.ui.table"
        enableSelectAll="false"
        selectionMode="MultiToggle">
      

      这篇关于如何隐藏表格中的“全选"-复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆