如何以不同颜色显示树形表的展开行 - SAP UI5

问题描述 投票:0回答:1

我试图以不同的颜色显示树表的展开行。有什么办法可以做到吗。目前,我的表格有备用行颜色 - 灰色和白色。现在,当我扩展树表节点时,子节点也遵循相同的颜色模式。我想将儿童的背景颜色突出显示为蓝色或其他颜色。但是,我知道,由于行数据是动态渲染的,因此不可能提前知道哪些行是子行并将它们设置为蓝色。 有任何想法吗?

View.xml

<table:TreeTable id="List"
   rows="{path:'List>/', parameters: {arrayNames:['childNodes']}}" selectionMode="None" rowHeight="46px" visibleRowCount="10" toggleOpenState="rowExpanded" enableSelectAll="false" >
<table:columns>
<table:Column filterProperty="Code">
   <Label text="ListColNumber"/>
   <table:template>
      <Text text="{List>Part}" wrapping="false"/>
   </table:template>
</table:Column>
<table:Column filterProperty="Name">
   <Label text="ListColName"/>
   <table:template>
      <HBox class="sapUiMediumMarginEnd" justifyContent="SpaceBetween">
         <Text text="{path:'List>PartName'}"/>
         <Text width="200px" visible="{= ${List>node} === 'Child'}" text="Lot:{path:'List>Lot'}"/>
      </HBox>
   </table:template>
</table:Column>

控制器.js

// 我试图获取展开的行的索引,然后计算子行的数量,然后为子行分配背景颜色。我犯了一些错误。

        var rowPath = event.getParameters().rowContext.getPath();
        var index = event.getParameters().rowIndex;

        var a = this.getView().getModel("inventoryList").getProperty("/1/childNodes");

        // In InventoryList model there are about 19 array rows being 
        returned. I wanted to access the exact row that is being expanded 
        using the rowPath and then traverse to the childNodes property of 
        that row. ChildNodes is also an array and will tell me how many 
        children are there. I did not know how to do that exactly so gave 
       /1/childnode to test


        var b = this.getView().byId("inventoryList");
        for (var i = 1; i < a.length; i++) 
        {
        var childRow = b.getRows()[i + 1];
        childRow.addStyleClass("red");  // this gives error

        }
sapui5
1个回答
0
投票

最后有什么解决方案可以解决这个问题吗?谢谢。

© www.soinside.com 2019 - 2024. All rights reserved.