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

时间:2018-08-22 19:37:59

标签: sapui5

我试图用不同的颜色显示树形表的扩展行。有没有办法做到这一点。目前,我的表有其他行颜色-灰色和白色。现在,当我扩展树表节点时,子级也遵循相同的颜色模式。我想将儿童的背景色突出显示为蓝色或其他某种颜色。但是,我知道随着行数据的动态呈现,不可能事先知道哪些行是子行并使它们变为蓝色。 有任何想法吗?

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>

Controller.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

        }

0 个答案:

没有答案