Change Text Font to Bold - sapui5

I have a table (sap.m.Table) and would like to change the header font to bold, but I'm unable to do that. Here is my code for one of the column definitions in my *.view.xml:
<Column xmlns="sap.m"
hAlign="Left"
width="17em"
>
<Text text="Vendor" />
</Column>
After looking at the API (sap.m.Text), I don't see a way to change the text style and I'm also new to UI5. Could someone point me to where to look for this?

sap.m.FormattedText
Another option is to use sap.m.FormattedText[api] with an inline tag <strong> within the htmlText value.
<Column ...>
<FormattedText htmlText="<strong>My Column</strong>" />
</Column>
Note
In XML, the character < needs to be escaped with <.
Browsers do not guarantee that the text within <strong> is always displayed in bold.
The <strong> element is for content that is of greater importance, while the <b> element is used to draw attention to text without indicating that it's more important. [source]
The element <b> is currently not supported by the FormattedText. On the other hand, <em> is supported to emphasize the text.

sap.m.Label
Instead of sap.m.Text, you can use sap.m.Label which supports "Bold" design.
<Column id="myColumn">
<Label labelFor="myColumn"
design="Bold"
text="..."
wrapping="true"
/>
</Column>
Additionally, enable the property wrapping (available since 1.50) in order to achieve the default behavior of sap.m.Text. Wrapping should be enabled for column headers as recommended by Fiori design guidelines:
Column Headers - Best Practices
Use controls that wrap [...]. Do not use controls that truncate.
Note: If the label is not labeling anything, please try with different controls like sap.m.FormattedText.

I found by chance that using <FormattedText> instead of <Text> creates bold headers. This works without (!) using any additional bold or strong markup in the htmlText of <FormattedText>.
So in your case you would go with:
<Column
hAlign="Left"
width="17em"
>
<FormattedText htmlText="Vendor" />
</Column>
Whether this works seems to be somewhat dependent on the SAPUI5 version and the theme in use.
It works for me on SAPUI5 1.108 with the default theme (no data-sap-ui-theme specified in index.html).

Try like in the Documentation
Create a custom CSS
Add your styleclass to the Control.

Related

Move 1st column header to each row in certain width

Whenever the browser size goes below Desktop width, I want my responsive table to hide the column headers and instead place them in the same row as its corresponding values for each entry.
Here is a visual example of what I want:
Desktop width
Below desktop width
It seemed to me that the way to achieve this behavior was by adding...
minScreenWidth="desktop"
demandPopin="true"
...to the <Column> tag, but this does not work for the 1st column.
So my question is: How to (nicely) implement that behavior for the 1st column?
Here's my minimal example code (I changed the Table.view.xml of this example):
<Table items="{/ProductCollection}">
<columns>
<Column>
<Text text="Supplier" />
</Column>
</columns>
<ColumnListItem>
<Label text="{SupplierName}" />
</ColumnListItem>
</Table>
Responsive table doesn't allow pushing all column headers to the items. From the API reference:
The sap.m.Table control requires at least one visible sap.m.Column in the columns aggregation, therefore applications must avoid configuring all columns to be shown in the pop-in. If such a conflict is detected, then the table prevents one column from moving to the pop-in.
You'll have to add at least one more column so that the 1st column does pop-in.
Related GitHub issue: https://github.com/SAP/openui5/issues/1396

How to make only one cell editable in smart table sapui5

I am using a sapui5 smart table to list down my products. It includes product code, product description and order quantity.
Among these three fields i want to update only the order quantity. It should be an inline editing in the table.
In my smart table i have enabled the property "editable" as "true". It makes the entire row is editable. Instead of making entire row editable, i want make only one cell to be editable.
Example
<smartFilterBar:SmartFilterBar id="smartFilterBar" entityType="ZDEMO_C_MyEntityType" persistencyKey="SmartFilter_Explored">
</smartFilterBar:SmartFilterBar>
<smartTable:SmartTable id="mySmartTable"
smartFilterId="smartFilterBar"
tableType="GridTable"
editable="true"
entitySet="ZDEMO_C_MyEntity"
useVariantManagement="false"
useTablePersonalisation="true"
header="My Products"
showRowCount="true"
useExportToExcel="true"
enableAutoBinding="true">
</smartTable:SmartTable>
I can see 2 ways:
Make use of "field controls" concept. It requires adding a special properties within your entity type, which define the state of the fields (cells). Also some annotations have to be introduced (in the metadata.xml by backend) to initiate the handling.
Here is a link where concept described using Form control as an example, but the same rules are applicable for Table as well:
https://blogs.sap.com/2017/06/06/dynamic-field-control-using-annotations-in-sapui5/
Redefine the table rows manually in your XML and bind the needed cell(s) against the property of the local JSON model, which could be changed depending on some conditions (e.g. Edit button press).
The 1st approach is better from the architectural perspective but requires some data model modifications (from the backend side).
The 2nd approach allows to do everything on UI and program some complex UI logic, which defines the cells state.
You choose.
You can add a sap ui table inside the smart table and add columns with customdata property. Follow these steps.
Make editable="true" as editable="false"
In your xml, make sure to add this namespace xmlns:core="sap.ui.core"
Within the smarttable tag add below.
<smartTable:SmartTable .................................
<Table>
<columns>
<Column>
<customData>
<core:CustomData key="p13nData" value='\{"columnKey": "OrderQty", "leadingProperty": "OrderQty", "columnIndex":"2"}'/>
</customData>
<Text text="Order Qty"/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Input value="{OrderQty}" type="Number" editable="true"/>
</cells>
</ColumnListItem>
</items>
</Table>
</smartTable:SmartTable>
Add below tag inside table to make your column editable
<table:Column sortProperty="Max_Capacity" filterProperty="Max_Capacity" id="maxCapCol">
<Label text="Max Capacity"/>
<table:template>
<Input text="{Max_Capacity}" />
</table:template>
</table:Column>

How to set additionalText for items of MultiComboBox

I'd like to add additionalText property while using sap.m.MultiComboBox. My view looks as follows:
<MultiComboBox items="{/list}" width="17rem" >
<core:ListItem key="{Name}" text="{Name}" additionalText="{Price}" />
</MultiComboBox>
But this doesn't seem to work as ListItem is not an aggregation for MultiComboBox.
As of UI5 1.60
The control sap.m.MultiComboBox now supports the property showSecondaryValues which should be used together with additionalText in <core:ListItem>.
<MultiComboBox xmlns="sap.m" showSecondaryValues="true" items="{/ProductCollection}">
<core:ListItem key="{ProductId}" text="{Name}" additionalText="{ProductId}" />
</MultiComboBox>
Sample: MultiComboBox - Two columns layout
UI5 1.58 and below
The problem is that, initially, the control Multi Combo Box was not designed to display more than one attribute in the list. According to the Fiori Design Guideline:
Do not use the multi-combo box if you need to display more than one attribute.
I wouldn't suggest to invest much time to do any hack around this limitation making the app more error-prone and less maintainable. Instead, use an alternative control such as Select Dialog with the option multiSelect: true.
The guideline also mentions Value Help Dialog as an option. But it's currently closed sourced and thus not available in OpenUI5 yet.
Would concatenating the text property work for you? As you don't seem to be able to define a really additional text, a workaround should be something like this:
<MultiComboBox items="{/list}" width="17rem" >
<core:Item key="{Name}" text="{Name}: {Price}" />
</MultiComboBox>
<ComboBox
showSecondaryValues= "true"
items="{
path: '/ProductCollection',
sorter: { path: 'Name' }
}">
<core:ListItem key="{ProductId}" text="{Name}" additionalText = {CurrencyCode}"/>
refer this

sap.m.IconTabFilter: How to display full text with icon?

I want to display IconTabBar with full texts and icons. How to fix it? With showAll="true", full text is used but without icon.
showall does not work in this way. It has nothing to do with wrapping of text items.
Form the API documentation for sap.m.IconTabFilter: "Enables special
visualization for disabled filter (show all items).
Default value is false."
Possible Solution: Use CSS to increase the size of the single IconTabFilters or disable the text wrapping using CSS.
If your labels get truncated, consider using shorter labels or text tabs (without icons), as text tabs cannot get truncated.
The text-only variant is one of the most common types. It allows longer labels, and can also display counters above the text to indicate the number of items on the tab page.
Unlike all other tab variants, the labels do not get truncated. The full text is always shown.
<IconTabBar>
<items>
<IconTabFilter icon="sap-icon://hint">
<l:SimpleForm minWidth="1024">
<core:Title text="Address"/>
<Label text="Name"/>
<Text text="{BuyerName}"/>
<Label text="Created At"/>
<Text text="{CreatedAt}"/>
<Label text="Created By Bp"/>
<Text text="{CreatedByBp}"/>
</l:SimpleForm>
</IconTabFilter>
<IconTabFilter icon="sap-icon://attachment">
<l:SimpleForm id="SupplierForm" minWidth="1024">
<Label text="status"/>
<Label text="Name" />
<Input value="{BuyerName}">
</Input>
</l:SimpleForm>
</IconTabFilter>
</items>
</IconTabBar>

Text field in matrix layout

I want to place a text field in a matrix layout. Please check below code and please suggest how to check XML code errors? Every time I stuck in designing the XML code. Please suggest me how to overcome that.
<core:View
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:l="sap.ui.commons.layout"
controllerName="matrix.matrix"
xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="ytftfhgff">
<content>
<l:MatrixLayout layoutFixed="true" columns="4" width="600px" widths="150px,150px,150px,150px">
<l:MatrixLayoutRow>
<l:MatrixLayoutCell colSpan="4">
<Text text="Its a heading" />
</l:MatrixLayoutCell>
</l:MatrixLayoutRow>
<l:MatrixLayoutRow>
<l:MatrixLayoutCell>
<Label text="First Name"/>
</l:MatrixLayoutCell>
<l:MatrixLayoutCell>
<TextField id="axscx" width="20em"></TextField>
</l:MatrixLayoutCell>
</l:MatrixLayoutRow>
</l:MatrixLayout>
</content>
</Page>
</core:View>
Thanks in advance,
sriman.
In general the errors logged by the XMLTemplateParser to the console should be understandable enough to get a basic idea of what's going wrong. In your case it is quite simple. The default namespace is set to "sap.m", i.e. the runtime tries to load the TextField control from that library. This cannot work as sap.m does not have a TextField control.
You can either use the Input control, i.e. replace TextField with Input. Or introduce an additional namespace:
xmlns:commons="sap.ui.commons"
and define the TextField in the following way:
<commons:TextField id="axscx" width="20em"/>
I would prefer using the Input field.