Sapui5 基于表的行索引(行号)和模型数据的属性操作图标属性

Sapui5 基于表的行索引(行号)和模型数据的属性操作图标属性,sapui5,Sapui5,我将XML视图中的表设置为: <Table id="testtable" xmlns="sap.ui.table" rows="{/testdata}" alternateRowColors="true"> <columns> <Column hAlign="Center" label="Col1"> <template> <m:Text text="{dataX}" wrapping="fal

我将XML视图中的表设置为:

<Table id="testtable" xmlns="sap.ui.table"
  rows="{/testdata}"
  alternateRowColors="true">
  <columns>
    <Column hAlign="Center" label="Col1">
      <template>
        <m:Text text="{dataX}" wrapping="false" />
      </template>
    </Column>
    <Column hAlign="Center" label="Col2">
      <template>
        <m:Text text="{dataY}" wrapping="false" />
      </template>
    </Column>
    <Column label="Col3">
      <template>
        <m:HBox>
                <core:Icon src="sap-icon://show" color="{path: 'test', formatter: '.setIconColour'}" />
                <core:Icon src="sap-icon://edit" color="{path: 'test', formatter: '.setIconColour'}" />
                <core:Icon src="sap-icon://print" color="{path: 'test', formatter: '.setIconColour'}" />
        </m:HBox>
      </template>
    </Column>
  </columns>
</Table>

这里我可以知道如何检查多个条件,例如

1) 基于
测试
值和
行数(索引)
(或)数组的哪个索引及其相应的
测试
值操作颜色属性

从上面看,如果我没有错的话,我可以认为是将多个参数传递给seticonclour(行/索引号和测试)值


我想知道我该怎么做,希望清楚:)

对于多变量格式化程序,对格式化控件使用以下语法:

<core:Icon src="sap-icon://show" color="{ parts : [ 'test', 'dataX' ], formatter: '.setIconColour'}" />

将多个参数传递给你的格式化程序。嘿@Marc,我有这个想法,但我可以知道我该怎么做。。。一个让我做休息的例子:)你有没有试过用谷歌搜索
sapui5格式化程序的多个参数?@Codenewbie好的,你能相应地更新这个问题吗?拥有
dataX
非常令人困惑,这导致了下面的答案,而实际目标是没有
dataX
,对吗?@codenubie关于最后一个问题:解释何时调用格式化程序以及如何处理。先生,这里我只想做最后一行,或者如果只有一行我想为图标显示不同的颜色,我可以知道如何实现这一点吗?让不同图标的颜色取决于不同的变量
<core:Icon src="sap-icon://show" color="{ parts : [ 'test', 'dataX' ], formatter: '.setIconColour'}" />
setIconColour: function (testValue, dataX) {

  if (testValue === 0 && dataX === 1) {
    return "Default";
  } else if (testValue === 0 && dataX === 2) {
    return "#ff0000";                            
  } else if (testValue === 1) {
    return "#007bff";
  } else if (testValue === 2) {
    return "Positive";
  } else if (testValue === 3) {
    return "Negative";
  } 
},