How to set the ProcessFlowLaneHeader state with JSON-model?

时间:2018-10-02 09:06:46

标签: sapui5

i'm currently working on an SAPUI5 app which includes a Process Flow control. I want to set the state of the ProcessFlowLaneHeader according to values in my JSON-model but it keeps changing to a state represting each existing state of the nodes. So I want the "donut" to show 2/3 of green, 1/12 of grey and 1/4 of red color(see JSON below). Instead it shows me 1/3 of each. When I look at the properties of the ProcessFlowLaneHeader through the UI5 Inspector while the app is running it shows me:

state: {
0: {
  "state": "Positive",
  "value": 1
}
1: {
  "state": "Negative",
  "value": 1
}
2: {
  "state": "Neutral",
  "value": 1
}
3: {
  "state": "Planned",
  "value": 0
}
4: {
  "state": "Critical",
  "value": 0
}

Did i make a mistake or is SAUPUI5 just overwriting my state? How can I set the state of the ProcessFlowLaneHeade?(onInit on controller?)

My JSON:

...
"lanes": [{
    "id": "0",
    "icon": "sap-icon://sales-quote",
    "label": "MoBe",
    "position": 0,
    "state": [{
        "state": "Positive",
        "value": 8
    }, {
        "state": "Negative",
        "value": 1
    }, {
        "state": "Neutral",
        "value": 3
    }, {
        "state": "Planned",
        "value": 0
    }, {
        "state": "Critical",
        "value": 0
    }]
},
...

My View:

<ProcessFlow id="processflow1" foldedCorners="false" wheelZoomable="false" class="PFLayoutSpec" nodes="{Monitor1>/nodes}" lanes="{Monitor1>/lanes}">
    <nodes>
        <ProcessFlowNode laneId="{Monitor1>lane}" nodeId="{Monitor1>id}" title="{Monitor1>title}" children="{Monitor1>children}" state="{Monitor1>state}" value="{Monitor1>value}" stateText="{Monitor1>stateText}" texts="{Monitor1>texts}" highlighted="{Monitor1>highlighted}" focused="{Monitor1>focused}" titleAbbreviation="{Monitor1>titleAbbreviation}"/>
    </nodes>
    <lanes>
        <ProcessFlowLaneHeader laneId="{Monitor1>id}" iconSrc="{Monitor1>icon}" text="{Monitor1>label}" position="{Monitor1>position}" state="{Monitor1>state}" press="onChangeDonut"/>
    </lanes>
</ProcessFlow>

Thank you for your help!

1 个答案:

答案 0 :(得分:0)

因为要以nodes聚合形式显示文档,所以ProcessFlowLaneHeader状态是根据文档的状态自动计算的。

请参见documentation

  

在ProcessFlowLaneHeader的'state'属性中使用此类型。例如,如果显示的车道没有文档,则应用程序开发人员可以设置车道标题的状态。如果显示了完整的流程(即,如果在行头中显示了下面的文档),则该行头的给定状态值将被忽略,并将根据文档的当前状态在ProcessFlow中进行计算。