SAPUI5 - Responsive sap.m.Table - header

I created a sap.m.table with its header headerToolbar.
In the header, I put the title and two SelectList separated by a ToolbarSpacer.
The problem is that when the screen size is small the elements on the headerToolbar don't go back to the next line and are truncated ...
On a large screen:
On a small screen:
I want the header to be responsive, that is the elements should go to the next line if there is no sufficient space.
Here is the code:
<headerToolbar height="auto">
<Toolbar height="auto">
<content>
<Title id="tableHeader" text="..."/>
<ToolbarSpacer />
<Label text="..." lableFor="sl1"/>
<SelectList id="sl1"
enabled="true">
<core:Item key="..." text="..." />
<core:Item key="..." text="..." />
</SelectList>
<ToolbarSpacer />
<Label text="..." lableFor="sl2"/>
<SelectList id="sl2"
enabled="true">
<core:Item key="..." text="..." />
<core:Item key="..." text="..." />
</SelectList>
<ToolbarSpacer />
</content>
</Toolbar>
</headerToolbar>

Why you don't use OverflowToolbar instead of Toolbar?
Is the official responsive Toolbar
https://sapui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.OverflowToolbarFooter/preview
If you don't like it and want this "pop-in" behaviour you have described, I guess you can put a FlexBox inside your Toolbar and set the direction property depending on the "device" model.
Using expression binding will be something like this:
new sap.m.FlexBox({
direction: "{= ${device>/isPhone} ? 'Column' : 'Row' }",
items: [
//Your content goes here
]
})
More here: https://sapui5.hana.ondemand.com/#docs/guide/69a8e469fbde46e7b8916250080effbd.html

You can enable horizontal table scrolling in the css:
.enableTableScrolling {
overflow-x: scroll;
}
After that table will not be truncated.

Related

Positioning actionbar items on android

I have this code
<template>
<Page>
<ActionBar title="Action Items">
<StackLayout orientation="horizontal">
<Image src="res://icon" width="40" height="40"
verticalAlignment="center" />
<Label text="NativeScript" fontSize="24"
verticalAlignment="center" />
</StackLayout>
<NavigationButton text="Go Back" android.systemIcon="ic_menu_back"
(tap)="onNavBtnTap()">
</NavigationButton>
<ActionItem (tap)="onShare()" ios.systemIcon="9"
ios.position="left" android.systemIcon="ic_menu_share"
android.position="actionBar">
</ActionItem>
<ActionItem (tap)="onDelete()" ios.systemIcon="16"
ios.position="right" text="delete" android.position="popup">
</ActionItem>
</ActionBar>
<ScrollView>
<StackLayout class="home-panel">
<!--Add your page content here-->
<Label textWrap="true" text="Play with NativeScript!"
class="h2 description-label">
{{first}}
</Label>
<Label textWrap="true"
text=" Write code in the editor or drag and drop components to build a NativeScript mobile application."
class="h2 description-label" />
<Label textWrap="true"
text="Scan the QR code with your mobile device and watch the changes sync live while you play with the code."
class="h2 description-label" />
</StackLayout>
</ScrollView>
</Page>
</template>
<script>
export default {
data() {
return {
first: "Once"
};
}
};
</script>
<style scoped>
.home-panel {
vertical-align: center;
font-size: 20;
margin: 15;
}
.description-label {
margin-bottom: 15;
}
</style>
which produces
My question is how come the back button aligned itself left and the others right without explicitly coding left or right?
<NavigationButton text="Go Back" android.systemIcon="ic_menu_back"
(tap)="onNavBtnTap()">
</NavigationButton>
and the other buttons are aligning to the right
<ActionItem (tap)="onShare()" ios.systemIcon="9"
ios.position="left" android.systemIcon="ic_menu_share"
android.position="actionBar">
</ActionItem>
<ActionItem (tap)="onDelete()" ios.systemIcon="16"
ios.position="right" text="delete" android.position="popup">
</ActionItem>
<NavigationButton/> is by default on the left, as it's just calls into the native setNavigationIcon api:
https://developer.android.com/reference/android/widget/Toolbar#setNavigationIcon(android.graphics.drawable.Drawable)
While the other <ActionItem> elements are added with the Menu api:
https://developer.android.com/reference/android/widget/Toolbar#getMenu()
For your other question, you can do the following:
<Label :text="`${first} Play with NativeScript!`" textWrap="true" class="h2 description-label" />
:text makes it a binding, the then you pass in a regular JavaScript string literal.
An alternative would be:
:text="first + ' Play with NativeScript!'"
Both ways should work fine.

<render-mode> not working with dynamic Material UI

I use the <render-mode> tag to include some html in my screen:
<?xml version="1.0" encoding="UTF-8"?>
<screen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/xml-screen-2.1.xsd"
require-authentication="anonymous-all">
<widgets>
<label type="h1" text="Hello world!"/>
<render-mode>
<text type="html,vuet" location="component://tutorial/template/hello.html"/>
</render-mode>
<label type="h1" text="after Hello world!"/>
</widgets>
</screen>
The incuded hello.html file is shown fine using the "standard UI" or "dynamic Bootstrap UI", but it doesn't show when using the "dynamic Material UI".
Is there a way to enable this? I much prefer the look and navigation of the dynamic Material UI.
Thank you!
The reason it doesn't show under qapps is that qapps uses a new render mode 'qvt' just like vapps uses the render mode 'vuet'. To make it show under /qapps just change:
<text type="html,vuet" ...
to:
<text type="html,vuet,qvt" ...

How to make a full width render on ReferenceManyField?

I have a react-admin show page configured with some ReferenceManyField components like this one:
<ReferenceManyField
reference="children"
target="userId"
label="Enfants"
>
<Datagrid
rowClick="edit"
>
<TextField
source="lastName"
label="Nom"
/>
<TextField
source="firstName"
label="Prénom"
/>
<DateField
source="birthday"
label="Date de naissance"
showTime={false}
/>
<TextField
source="phoneNumber"
label="Tél."
/>
</Datagrid>
</ReferenceManyField>
It works, but the rendered tab are content sized:
My question is quite simple: How to make it full width?
I tried the fullWidth option on ReferenceManyField without any effect.

How to use <ios> or <android> elements in Nativescript Vue

I would like to do this
```xml
<android>
<NavigationButton
text="Go Back"
android.systemIcon="ic_menu_more"
#tap="$refs.drawer.nativeView.showDrawer()"/>
</android>
<ios>
<ActionItem
text="Menu"
#tap="$refs.drawer.nativeView.showDrawer()" />
</ios>
</ActionBar>
```
What is the best way to go about it ?
As posted here https://github.com/nativescript-vue/nativescript-vue/issues/180#issuecomment-380844535
You can use these elements like you did, but the ActionBar is a bit different (hence why it doesn't work as you'd expect). What I've done in a project was to add
// main.js
import { isAndroid, isIOS } from 'tns-core-modules/platform';
Vue.prototype.$isAndroid = isAndroid;
Vue.prototype.$isIOS = isIOS;
In template
<ActionBar android.icon="ic_home" class="action-bar" title="Home">
<NavigationButton
v-if="$isAndroid"
text="Go Back"
android.systemIcon="ic_menu_more"
#tap="$refs.drawer.nativeView.showDrawer()"/>
<ActionItem
v-else
text="Menu"
#tap="$refs.drawer.nativeView.showDrawer()" />
</ActionBar>

Flex List Component with Checkbox

I am trying to add a checkbox to a List component in my application and everything works seeming well until I scroll through my data.
As I scroll vertically in my List, any checks I may have added start to get added to other items in my List, sometimes the original item I checked is not even checked anymore.
For example, my List height is enough to see 5 items, I check Item 1, scroll down and every 5th item starts to get checked.
It's really odd and I have not been able to figure out why it is doing this. I looked at some examples online, and I'm not doing anything any different as far as I can tell.
I ran some traces and the Checkbox datachange event fires as I scroll through my list, but again, I am not sure why.
Here is the mxml test page for my List.
Any help is appreciated, thanks.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Array id="arr">
<mx:Object label="One" />
<mx:Object label="Two" />
<mx:Object label="Three" />
<mx:Object label="Four" />
<mx:Object label="Five" />
<mx:Object label="Six" />
<mx:Object label="Seven" />
<mx:Object label="Eight"/>
<mx:Object label="Nine" />
<mx:Object label="Ten" />
<mx:Object label="Eleven" />
<mx:Object label="Twelve" />
</mx:Array>
<mx:List
id="addrList"
height="100"
width="100%" fontSize="10"
borderStyle="solid"
borderColor="#000000"
borderThickness="1"
dataProvider="{ arr }">
<mx:itemRenderer>
<mx:Component>
<mx:CheckBox
change="trace('change')"
dataChange="trace('dataChange')"/>
</mx:Component>
</mx:itemRenderer>
</mx:List>
</mx:Application>
your putting an object to a list dataprovider, dataprovider supports text only
try this
<mx:Script>
<![CDATA[
[Bindable]
private var arr:Array = ["a","b","c","d","e","f","g"];
]]>
</mx:Script>
<mx:List
id="addrList"
height="100"
width="100%" fontSize="10"
borderStyle="solid"
borderColor="#000000"
borderThickness="1"
dataProvider="{ arr }">
<mx:itemRenderer>
<mx:Component>
<mx:CheckBox change="trace('change')"
dataChange="trace('dataChange')"/>
</mx:Component>
</mx:itemRenderer>
</mx:List>