The final view should like this:
The code in view.xml like this:
<VBox height="90px">
<Label text="{i18n>FISCALYEAR_LABEL}" mandatory="mandatory"/>
<Select id="FiscalYear"
items="{
path: '/FiscalYearSet',
sorter: { path: 'FiscalYearID' }
}">
<core:Item key="{FiscalYearID}" text="{FiscalYearNum}" />
</Select>
<ComboBox
items="{
path: '/FiscalYearSet',
sorter: { path: 'FiscalYearID' }
}">
<core:Item key="{FiscalYearID}" text="{FiscalYearNum}" />
</ComboBox>
</VBox>
I set a property 'mandatory="mandatory"', but it does not work.
<Label text="{i18n>FISCALYEAR_LABEL}" required='true'/>
required is one of the properties of sap.m.InputBase with default boolean value set to false
Related
BottomNavigation component requires to put all tab contents on same page.
e.g:
<TabContentItem>
<GridLayout>
<Label text="Home Page" class="h2 text-center"></Label>
</GridLayout>
</TabContentItem>
<TabContentItem>
<GridLayout>
<Label text="Account Page" class="h2 text-center"></Label>
</GridLayout>
</TabContentItem>
<TabContentItem>
<GridLayout>
<Label text="Search Page" class="h2 text-center"></Label>
</GridLayout>
</TabContentItem>
I think pages are loaded like a dynamic component. I want to have tabs only with route links. When user tap a tab, I will redirect user to another page.
If I don't use TabContentItem, TabStripItems are also not shown on page. So, I added them with empty contents.
Using selectedIndexChange event I can redirect user to another page, but when one of the tab links is current page, it goes to infinite loop.
It seems like tabs has to be on a different page on this setup. This is not something I want.
Is there a way to convert the BottomNavigation component to a route based one?
Here my current code is:
(It is a Vue project.)
<template>
<BottomNavigation selectedIndex="0" #selectedIndexChange="indexChange">
<TabStrip #itemTap="test">
<template v-for="(tab, key) in tabs">
<TabStripItem :key="key">
<Label :text="tab.title"></Label>
</TabStripItem>
</template>
</TabStrip>
<template v-for="(tab, key) in tabs">
<TabContentItem :key="key">
<GridLayout>
</GridLayout>
</TabContentItem>
</template>
</BottomNavigation>
</template>
<script>
export default {
props: {
tabs: {
type: Array,
required: true
}
},
created () {
},
methods: {
indexChange: function (args) {
let newIndex = args.value
let route = this.tabs[newIndex].route
this.goToPage(route)
},
goToPage (route) {
this.$navigator.navigate(route)
}
}
}
</script>
I'm battling to make the textfield when selected to be above the keyboard:
Tried this code:
HTML:
<StackLayout class="input-field">
<Label text="Postal Code" class="label font-weight-bold m-b-5"
</Label>
<TextField #postalCode id="postalCode" (tap)="onFocus()"
[(ngModel)]="model.address.postal_code" class="input" ></TextField>
</StackLayout>
TS:
onFocus() {
let postalCode = <TextField> this.postalCode.nativeElement;
console.log(postalCode.focus());
}
If you want to push the textfield up when the keyboard is selected, open App_Resources/Android/AndroidManifest.xml and add this to the <activity: android:windowSoftInputMode="stateHidden|adjustResize".
First I implemented the code below.
app.component.html
<StackLayout [formGroup]="form">
<label text="Name"></label>
<TextField formControlName="Name"></TextField>
<label text="Last Name"></label>
<TextField formControlName="LastName"></TextField>
<button text="save" (tap)="save()"></button>
</StackLayout>
app.component.ts
public form: FormGroup;
constructor(private fb: FormBuilder){
this.form = this.fb.group({
"Name": ["", [Validators.required]],
"LastName": ["", [Validators.required]]
});
}
public save(){
console.log(JSON.stringify(this.form.value));
}
When I run the code above, it's everything alright. I get name and lastname correctly.
The problem occurs when I try to add an action bar to this code.
app.component.html
<ActionBar title="New" class="action-bar">
<ActionItem text="save" (tap)="save()"></ActionItem>
</ActionBar>
<StackLayout [formGroup]="form">
<label text="Name"></label>
<TextField formControlName="Name"></TextField>
<label text="Last Name"></label>
<TextField formControlName="LastName"></TextField>
<button text="save" (tap)="save()"></button>
</StackLayout>
The app.component.ts remains the same.
When I run this code and tap the button inside stacklayout I get name and lastname correctly but when I tap the ActionItem I get an empty string for both name and lastname. Am I missing something?
Your code looks just fine - in fact I have re=-tested it with this test application and everything works as expected on my side.
Side note: If testing on iOS keep in mind that subsequent console logs can be printed only once if they are identical. (this) so it might be that it appears that the log is not printed when in fact the action is done.
On my xml, I have 1 textfield and 1 datepicker. How do I get a datepicker result and storing it result on the textfield?
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="onNavigatingTo">
<StackLayout>
<TextField hint="tanggalprospek" text="{{ tanggalprospek }}" />
<DatePicker day="15" month="5" year="2016" id="date" />
<Button text="Get Tap" tap="{{ getTap }}" />
</StackLayout>
</Page>
Many thanks for your help.. :)
Get the datepicker in the page controller and get the date value of it, then set it to the textfield along with the notifyPropertyChange event. I also use moment.js to have a good date format.
In the xml:
<Button text="Get Tap" tap="getTap" />
In the page controller:
var moment = require("moment");
export function getTap(args) {
var myDatePicker = page.getViewById("date");
var date = moment(myDatePicker.date);
var dateText = date.format("Do MMM [,] H:mm").toString();
page.bindingContext.set("tanggalprospek", dateText);
page.bindingContext.notifyPropertyChange("tanggalprospek", dateText);
}
P/s: I'm using TypeScript
I want a field to become required only when a specific option is selected or a specific radio button is selected or when a specific string is entered in a text input field (All of the required( dependency-expression ) examples I can find assume that the dependency is whether an input is checked / unchecked or filled/unfilled in the case of text fields)
Here is an example of what I need, based on a radio section:
Marital Status (the required field):
<input name="status" id='status'type="radio" value="couple" checked="checked" />
<input name="status" id='status'type="radio" value="single male" />
<input name="status" id='status'type="radio" value="single female" />
Partners Name (the dependent field - required only when 'Couple' is selected from above)
<input name="partner" type="text" id="partner">
Example 2: Required field = Venue
<select name="venue" id="venue">
<option value="">Please select venue</option>
<option>London EC1</option>
<option>London E9</option>
<option>Birmingham</option>
etc.
Dependent field = user (only required for one of the above selections, say 'Birmingham')
<input name="user" type="text" id="user">
How do I adapt the example shown athttp://docs.jquery.com/Plugins/Validation/Methods/required#dependency-expression for the above situations?
$("#myform").validate({
rules: {
details: {
required: "#other:checked"
}
}, debug:true
});
$("#other").click(function() {
$("#details").valid();
});
I have tried:
user: {
required: "#venue:('birmingham')"
}
and
partner: {
required: "#status:('couple')"
}
but these have the effect of making user and partner required regardless of results in venue and status
For the first one, your radio inputs should have different id's:
<input name="status" id='statusCouple' type="radio" value="couple" checked="checked" />
<input name="status" id='statusSingleMale' type="radio" value="single male" />
<input name="status" id='statusSignleFemale' type="radio" value="single female" />
Then your rule can look like this:
partner: {
required: "#statusCouple:checked"
}
For the second one, just make your rule like this:
user: {
required: function(element) { return $("#venue").val() == 'Birmingham'; }
}
Should do the trick.