带按钮的sap.ui.table.Table标题工具栏

时间:2018-06-15 09:03:57

标签: sapui5

我用sap.m.Table替换sap.ui.table.Table。以下标题代码适用于sap.m.Table但不适用sap.ui.table.Table网格布局。

用于sap.m.Table

的标头代码
<headerToolbar>
  <Toolbar class="sapMTBHeader">
    <Bar class="alertSummayBar">
      <contentLeft>
        <Label
          class="alert-label"
          text="{i18n>AlertSummRelatedAlertLabel}"
        />
      </contentLeft>
      <contentRight>
        <FlexBox
          class="alertsTablePagination"
          justifyContent="SpaceAround"
        >
          <Button id="policyChangeBtn"
            class="alertbutton"
            text="{i18n>AlertSummPolicyChangebutton}"
            press=".onPolicyChangeInfoPress"
            enabled="false"
          />
          <Button id="verifyBtn"
            class="alertbutton"
            text="{i18n>AlertSummVerifybutton}"
            press=".onVerifyOrRequestInfoPress"
            enabled="false"
          />
          <Button id="createTaskButtonId"
            class="alertbutton"
            text="{i18n>AlertsCreateTaskButtonText}"
            press=".onAlertsCreateTaskButtonPress"
            enabled="false"
          />
        </FlexBox>
      </contentRight>
    </Bar>
  </Toolbar>
</headerToolbar>
带网格布局的

sap.ui.table.Table代码

<grid:Table id="alertsSummaryTable"
  class="gridTable table"
  showNoData="false"
  selectionMode="None"
  visible="true"
  showColumnVisibilityMenu="false"
  rows="{/alertsSummaryTablePath}"
  rowSelectionChange="handleAlertsSummaryTable"
>
  <grid:Column
    sortProperty="principal"
    resizable="false"
    filterProperty="principal"
  >
    <Label text="{i18n>AlertTablePrincipleLabel}"/>
    <grid:template>
      <Text
        text="{principal}"
        tooltip="{principal}"
      />
    </grid:template>
  </grid:Column>
</grid:Table>

请帮助..

2 个答案:

答案 0 :(得分:0)

工具栏进入表格的工具栏聚合。请参阅文档中的此示例中的代码:

https://sapui5.hana.ondemand.com/#/sample/sap.ui.table.sample.Filtering/code

答案 1 :(得分:0)

请查看相应的API reference。网格表具有名为"toolbar"的聚合,但由于弃用,它建议使用聚合"extension"

  

工具栏:不推荐使用此聚合,而是使用扩展名聚合。

sap.ui.getCore().attachInit(() => sap.ui.require([
  "sap/ui/table/Table",
  "sap/m/Toolbar",
  "sap/m/Title",
  "sap/m/ToolbarSpacer",
  "sap/m/Button",
], (Table, Toolbar, Title, ToolbarSpacer, Button) => new Table({
  extension: new Toolbar({
    content: [
      new Title().setText("Header Toolbar with Buttons"),
      new ToolbarSpacer(),
      new Button().setIcon("sap-icon://add"),
      new Button().setIcon("sap-icon://edit"),
      new Button().setIcon("sap-icon://delete"),
    ],
  }).addStyleClass("sapMTBHeader-CTX")
}).placeAt("content").addStyleClass("sapUiSizeCondensed sapUiTinyMargin")))
<script>
  window["sap-ui-config"] = {
    libs: "sap.ui.core, sap.m, sap.ui.table, sap.ui.unified",
    preload: "async",
    theme: "sap_belize",
    "xx-waitForTheme": true,
    "xx-async": true,
  };
</script>
<script id="sap-ui-bootstrap" src="https://ui5.sap.com/resources/sap-ui-core.js"></script>
<body id="content" class="sapUiBody sapUiSizeCompact"></body>