sap.ui.table 表行选择器在 sapui5 中禁用 [英] sap.ui.table table row selector disable in sapui5

查看:16
本文介绍了sap.ui.table 表行选择器在 sapui5 中禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以禁用特定行的行选择器.setEnable 方法不适用于 sap.ui.table.请找到所附屏幕截图以便更好地理解.

Is it possible to disable row selector for particular rows. setEnable method is not available for sap.ui.table. Please find the attached screenshot for better understanding.

推荐答案

请通过以下代码.或许能帮到你.

please go through the following code. It might help you.

sap.ui.controller("my.controller", {
  onInit: function() {
    var model = new sap.ui.model.json.JSONModel([
      {Product: "Power Projector 4713", Weight: "33"},
      {Product: "Gladiator MX", Weight: "33"},
      {Product: "Hurricane GX", Weight: "45"},
      {Product: "Webcam", Weight: "33"},
      {Product: "Monitor Locking Cable", Weight: "41"},
      {Product: "Laptop Case", Weight: "64"}
    ]);
    
    var vw = this.getView();
    vw.setModel(model);
 
    
    // disable checkboxes
    var tbl = vw.byId('tblProduct');
    tbl.addDelegate({
      onAfterRendering: function() {
        var header = this.$().find('thead');
        var selectAllCb = header.find('.sapMCb');
        selectAllCb.remove();
        
        this.getItems().forEach(function(r) {
          var obj = r.getBindingContext().getObject();
          var enabled = parseInt(obj.Weight, 10) > 40;
          var cb = r.$().find('.sapMCb');
          var oCb = sap.ui.getCore().byId(cb.attr('id'));
          oCb.setEnabled(enabled);
        });
      }
    }, tbl);
  }
});

var oView = sap.ui.xmlview({
  viewContent: jQuery('#chartView').html()
}).placeAt('content');

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>JS Bin</title>
    <script 
            src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" 
            id="sap-ui-bootstrap" 
            data-sap-ui-theme="sap_bluecrystal" 
            data-sap-ui-xx-bindingSyntax="complex" 
            data-sap-ui-libs="sap.m"></script>
    <script id="chartView" type="sapui5/xmlview">
    <mvc:View
      controllerName="my.controller"
      xmlns:l="sap.ui.layout"
      xmlns:u="sap.ui.unified"
      xmlns:mvc="sap.ui.core.mvc"
      xmlns="sap.m"
      class="viewPadding">
      <App>
        <pages>
          <Page title="Table CheckBox Disable" class="marginBoxContent" >
            <content>
              <Table id="tblProduct" mode= "MultiSelect"
                selectionChange = "rowSelect"
                items="{/}">
                <columns>
                  <Column>
                    <Label text="Product" />
                  </Column>
                  <Column>
                    <Label text="Weight" />
                  </Column>
                </columns>
                <items>
                  <ColumnListItem>
                    <cells>
                      <Text  text="{Product}" />
                      <Text text="{Weight}" />
                    </cells>
                  </ColumnListItem>
                </items>
              </Table>
            </content>
          </Page>
        </pages>
      </App>
      </mvc:View>
    </script>
  </head>
  <body class="sapUiBody">
    <div id='content'></div>
  </body>
</html>

问候,法鲁克.

这篇关于sap.ui.table 表行选择器在 sapui5 中禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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