cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

HI,

I'm a SAPUI5 beginner, having a problem with if-else statement in XML view.

I'm trying to create a table in XML view. Values in table are binded from .json file (in the future, values will be binded via oData service). Below is the code.

<mvc:View
	controllerName="demo.prototype.controller.TestController"
	xmlns:t="sap.ui.table"
	xmlns:mvc="sap.ui.core.mvc"
	xmlns:u="sap.ui.unified"
	xmlns:c="sap.ui.core"
	xmlns="sap.m"
	xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1">
        <t:Table
			rows="{/ProductCollection}"
			visibleRowCount="7"
			selectionMode="MultiToggle"
			width="75rem">
		<t:columns>
			<t:Column width="10rem">
				<Label text="{i18n>modelGroup}" />
	        	<t:template>
					<Label text="{modelGroup}" />
				</t:template>
			</t:Column>
                        <t:Column width="4rem">
				<Label text="{i18n>line}" />
				<t:template>
					<Label text="{line}"/>
				</t:template>
			</t:Column>
                        <t:Column width="6rem">
				<Label text="{i18n>date}" />
				<t:template>
					<Input value="{data1}"
					       description="/100" />
				</t:template>
			</t:Column>
               </t:columns>
	</t:Table>
</mvc:View>

I want to switch Control(Input or Label) or to switch "display description or not" in Input control, depending on flg (true or false) in .json file. But I cannot find the way to do that. I found "http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1" in other questions and tried, but it did not work.

There are 2 ways probably・Implement in Controller ・Implement in XML view.

The 2nd way is preferable for me.

Could anyone help me?

If there is missing information, please point them out.

Thank you for your support.

View Entire Topic
junwu
SAP Champion
SAP Champion
0 Likes

you cannot use view with template directly. you have to pre-process the template.

use the easy way : a flag to control the visibility

0 Likes

Thank you for your comment and advice.

I read the document about pre-processing, but it takes a little more time for me to understand that...

I will implement with visible in control for now.