Expand input suggestion width - sapui5

Screenshot of the current width:
I'm trying to expand the suggestion popup above.
Since I want to use it in a FilterBar, the Input fields are small and the Table becomes kind of useless. When trying to change the width with the Inspector, it changes back immediately.
The demo code I'm using is rather simple.
<Input xmlns="sap.m"
showSuggestion="true"
showTableSuggestionValueHelp="false"
suggestionRows="{/ZSD_DebiaSet}"
width="200px">
<suggestionColumns>
<Column popinDisplay="Inline" demandPopin="true">
<Label text="Name"/>
</Column>
<Column hAlign="Center" popinDisplay="Inline" demandPopin="true" minScreenWidth="Tablet">
<Label text="Product ID"/>
</Column>
<Column hAlign="Center" popinDisplay="Inline" minScreenWidth="Tablet">
<Label text="Supplier Name"/>
</Column>
<Column hAlign="End" popinDisplay="Inline" demandPopin="true">
<Label text="Price"/>
</Column>
</suggestionColumns>
<suggestionRows>
<ColumnListItem>
<!-- ... -->
</ColumnListItem>
</suggestionRows>
</Input>

Controls extended from sap.m.Input (i.e. including sap.m.MultiInput) have a property called maxSuggestionWidth which will let you have a wider suggestion table than the actual width of your input. Check the property here: https://openui5.hana.ondemand.com/api/sap.m.Input#methods/setMaxSuggestionWidth
If set, the value of this parameter will control the horizontal size of the suggestion list to display more data. This allows suggestion lists to be wider than the input field if there is enough space available. By default, the suggestion list is always as wide as the input field.
Note: The value will be ignored if the actual width of the input field is larger than the specified parameter value.
I added this property with value 500px (just for testing) and the result is the following (The Input width is 200px):
I think this is what you are looking for ^^ Hope it helps!

Related

How to implement an editing mode in SAPUI5?

I'm currently building a dynamic table within a sapui5 application. Therefore I'm implementing an editing mode, which is triggered through the click of a button. To change the table cells between view- and edit mode, I defined the following cells:
<items>
<ColumnListItem>
<cells>
<Text text="{Name}" visible="{= !${/editMode}}"/>
<Input value="{Name}" visible="{= ${/editMode}}" change="onChangeName"/>
<Text .../>
<Input .../>
...
</cells>
</ColumnListItem>
</items>
Unfortunately, my code does not work as intended. For example, instead of column 1 switching between the "Text" and "Input" nodes, the text node is displayed in one column and the input node in the following column. How do I get the two nodes in the same column?
View mode (Text text...)
Edit mode (Input value...)
Solved it using SAPUI5's <HBox> tag (Click here for documentation)
The code now looks like that:
<items>
<ColumnListItem>
<cells>
<HBox>
<Text text="{Name}" visible="{= !${/editMode}}"/>
<Input value="{Name}" visible="{= ${/editMode}}" change="onChangeName"/>
</HBox>
<HBox>
<Text .../>
<Input .../>
</HBox>
...
</cells>
</ColumnListItem>
</items>

how to create an Expandable Column using ui5-table

How can I create an Expandable/Collapsable Columns like accordion using ui5-table? I couldn't find it within sap.ui.table.Table samples or don't even know if other tables supports this.
You could try something like this
Attach to the "columnPress" event of the column to detect a Click on the table column.
In the Event detect, if the expandable column is clicked and toggle a property in the ViewModel
switch the visibility in the the Column Template
<Column>
<m:Label text="Expand" />
<template>
<m:HBox>
<m:Text text="unexpanded" visible="{= !${viewModel>/IsExpanded}}"/>
<m:HBox visible="{= !!${viewModel>/IsExpanded}}">
<m:Text text="expanded1"/>
<m:Text text="expanded2"/>
<m:Text text="expanded3"/>
</m:HBox>
</m:HBox>
</template>
</Column>

sapui5 coordinate plotting

A question regarding below process. I have a table maintained in blue box. Sample table maintenance and expected output.
How could I render the coordinates to a clickable table/grid like what is shown in red box. Which SAPUI5 control able to achieve this objective? The X will be the lot id which will be maintained in the table and it shall have an event triggered to show the detail information when user click on the cell. Some lot will have single cell and some will need to merge cell(Note: if the coordinate is not maintained, it shall leaves blank to that cell and is non-clickable).
Does this requirment able to achive using sapui5 for fiori app?
There are several ways to achieve this, but not all of them offer the complete set of functionality that you describe.
The first way that comes into mind is to use a sap.m.Table with the "mergeDuplicates" properties set on the columns. Example (working fiddle here):
<Table>
<columns>
<Column mergeDuplicates="true">
<header><Label text="1" /></header>
</Column>
<Column mergeDuplicates="true">
<header><Label text="2" /></header>
</Column>
<Column mergeDuplicates="true">
<header><Label text="3" /></header>
</Column>
</columns>
<ColumnListItem>
<Button text="A"/>
<Button text="B"/>
<Button text="X"/>
</ColumnListItem>
<ColumnListItem>
<Button text="A"/>
<Button text="C"/>
<Button text="C"/>
</ColumnListItem>
<ColumnListItem>
<Button text="A"/>
<Button text="C"/>
<Button text="C"/>
</ColumnListItem>
</Table>
The main downside of this is that you cannot merge cells across columns (i.e. in this example, you would get cell "C" twice: once for the second column and once for the third).
Another version is to use the sap.ui.layout.Grid. This has mostly the same limitation (that you can only merge "cells" in a single direction) and also has the added limitation that:
The Grid control is a layout which positions its child controls in a 12 column flow layout.
Lastly, you could use a sap.ui.commons.layout.MatrixLayout (which is deprecated btw, but no "full" replacement was provided). This actually can be used to model your problem completely. Example (working fiddle here):
<layout:MatrixLayout class="matrix">
<layout:rows>
<layout:MatrixLayoutRow height="4em">
<layout:MatrixLayoutCell padding="None" rowSpan="3">
<Button text="A" width="100%"/>
</layout:MatrixLayoutCell>
<layout:MatrixLayoutCell padding="None">
<Button text="B" width="100%"/>
</layout:MatrixLayoutCell>
<layout:MatrixLayoutCell padding="None">
<Button text="X" width="100%"/>
</layout:MatrixLayoutCell>
</layout:MatrixLayoutRow>
<layout:MatrixLayoutRow height="4em">
<layout:MatrixLayoutCell padding="None" colSpan="2" rowSpan="2" >
<Button text="C" width="100%"/>
</layout:MatrixLayoutCell>
</layout:MatrixLayoutRow>
<layout:MatrixLayoutRow height="4em">
</layout:MatrixLayoutRow>
</layout:rows>
</layout:MatrixLayout>
But as you see, it is slightly more complicated and may need some CSS fiddling.

SAPUI5/Fiori: Multiple Step Inputs in one View (Duplicate Id)

I'm developing an app in SAPUI5/Fiori and I want to implement the "Step Input" control in a table for each row.
In the explored reference of Fiori, I copied the control code, but I currently get the following error:
Core-dbg.js:2711 Uncaught (in promise) Error: Error: adding element
with duplicate id '[..]--stepInput-decrementBtn'
My View looks like this:
<Table id="lineItemsList" width="auto" items="{/itemsSet}"class="sapUiResponsiveMargin">
<headerToolbar>
<Toolbar id="lineItemsToolbar">
<Title id="lineItemsHeader" text="{/lineItemListTitle}"/>
</Toolbar>
</headerToolbar>
<columns>
<Column vAlign="Middle">
<Text text="{i18n>detailLineItemTableIDColumn}"/>
</Column>
<Column hAlign="Right">
<Text text="{i18n>detailLineItemTableUnitNumberColumn}"/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Label id="label1" text="{itemID}"/>
<StepInput
id="stepInput"
value="0"
width="120px"
min="0"
max="15"
step="1"
editable="true"/>
</cells>
</ColumnListItem>
</items>
</Table>
I also tested to give the StepInput no id, but still the same error.
I have had a look at your problem. I did some tests based on the SAPUI5 example https://sapui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.StepInput/preview
And found that the problems comes from the property editable which if it is manually set to true provokes the error you found.
You have several choices:
You don't put this attribute, the field will be editable and it will work
Match the value of the attribute to an element of your model (as in the example), it will work even when the value is true
Also you should create a ticket to SAP to raise this problem which is problem a standard issue.
Hope this'll help !
Almiriad is right, this is a freaking bug in the latest versions, you can see it by debugging StepInput-dbg.js >> the decrement button creation method is sent twice (because the 'setEnaditable' checks the aggregation and creates the button)
Since true is the default value for editable property, you dont need it here :)

How to enable scrolling in sap.m.Table in sapui5?

I have implemented sap.m.Table but all the records are not displayed. Also there seems to be no option for scrolling. I went through the API which suggests using growing, growingThreshold, growingScrollToLoad of sap.m.ListBase.
Here growing would enable the table control to load more items, growingThreshold would determine the number of items to be requested from the model for each grow and getGrowingScrollToLoad would enable the user to scroll through the records instead of a more button being displayed to load more data.
However, even after using these properties my entire data is still not getting rendered and I can see that more button instead of scroll bar. Below the more button I am able to see a number that determines the entire number of records to be rendered as well and the number of records that have been rendered in the initial view.
Shouldn't scrolling be a default option if the data exceeds a page's limit? I'm very confused. Please help.
Also I did go through this post! :)
Update 8-March-2019 :
There is now a new way to enable scrolling in sap.m.Table with sticky option.
Kindly check the API and samples for more example. This new way is recommended and support and development is provided directly via the library.
Check: https://sapui5.hana.ondemand.com/#/api/sap.m.ListBase/methods/setSticky
Old Answer:
Given how the question is beautifully setup, with options:
sap.ui.table.Table : scrollable with fixed Header.
sap.m.Table: growing list, scrollable WITHOUT fixed header.
But many a times we need a sap.m.Table- scrollable but with static header, so the content below the table does not move further below. This below code will help during that time. It has a scrollable body with fixed header.
Setup: I'm using two sap.m.Table instances, one just with header and other just for data. Also, I'm using a scrollable container, which holds the 2nd table (without the header). Because of the fixed width of Scrollable container, we see a scrollbar. Dummy code is provided below:
View.xml:
<Table showNoData='false'>
<columns>
<Column>
<header>
<Text text='ID' />
</header>
</Column>
<Column>
<header>
<Text text='First Name' />
</header>
</Column>
<Column>
<header>
<Text text='Last Name' />
</header>
</Column>
<Column>
<header>
<Text text='Gender' />
</header>
</Column>
</columns>
</Table>
<ScrollContainer height='20rem' vertical='true'> <!-- To have fixed with and enable vertical scrolling of data table -->
<!-- Table to hold data, data ,data -->
<Table class='tableHdr' items='{/}'> <!-- CSS class to hide the column header, otherwise we will have 2 headers. -->
<columns>
<!-- Dont need columns header, as upper table has already defined them. -->
<Column >
</Column>
<Column >
</Column>
<Column >
</Column>
<Column >
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text='{id}' />
<Text text='{first_name}' />
<Text text='{last_name}' />
<Text text='{gender}' />
</cells>
</ColumnListItem>
</items>
</Table>
</ScrollContainer>
Now, If you execute the above code without this below style class, you will end up with 2 columns headers from 2 tables. So, to remove the 2nd Column header, I used the below class:
.tableHdr .sapMListTblHeaderCell {
padding: 0rem;
}
Would like to hear the feedback on this.
By default, if there are more rows in sap.m.Table, scrolling will be there.
You can see the working example here
But if you want to force to fixed rows visibility, you can use sap.ui.table.Table with the properties visibleRowCount and minAutoRowCount.
Also note that if the vertical scrollbar is not visible for sap.m.Table, check if some other css is overriding the style. Else you can paste the code in the question with full ui code.