How to change the RadDataForm style in nativescript-vue ? (Nativescript-Vue) - nativescript

How to change font-size, border-color e.t.c styling of email and password present in the person object.
<RadDataForm :source="person"</RadDataForm>

Here seems to be a perfect example you are looking, use TKPropertyEditorStyle to define custom font, size, color etc.,
<template>
<Page class="page">
<ActionBar title="Home" class="action-bar" />
<RadDataForm ref="dataForm" :source="person">
<TKEntityProperty v-tkDataFormProperty name="name">
<TKPropertyEditor v-tkEntityPropertyEditor type="Text">
<TKPropertyEditorStyle v-tkPropertyEditorStyle
labelTextColor="red"></TKPropertyEditorStyle>
</TKPropertyEditor>
</TKEntityProperty>
<TKEntityProperty v-tkDataFormProperty name="age">
<TKPropertyEditor v-tkEntityPropertyEditor type="Decimal">
<TKPropertyEditorStyle v-tkPropertyEditorStyle
labelTextColor="green"></TKPropertyEditorStyle>
</TKPropertyEditor>
</TKEntityProperty>
<TKEntityProperty v-tkDataFormProperty name="birthDate">
<TKPropertyEditor v-tkEntityPropertyEditor type="DatePicker">
<TKPropertyEditorStyle v-tkPropertyEditorStyle
labelTextColor="blue"></TKPropertyEditorStyle>
</TKPropertyEditor>
</TKEntityProperty>
</RadDataForm>
</Page>
</template>
<script>
import Vue from "nativescript-vue";
import RadDataForm from "nativescript-ui-dataform/vue";
Vue.use(RadDataForm);
export default {
data() {
return {
person: {
name: "John",
age: 23,
birthDate: "1993-05-16"
}
};
}
};
</script>

Related

I use #if in Svlte Native but it doesn't work

I try out Svelte Native and I try to hide "tags" with booleans. I try this, which works in the normal Svelte framework like:
{#if po.id !== null || po.id !== undefined}
<flexboxLayout flexWrap="wrap" class="v-a-c t-a-c" >
<label text="first" width="70%" backgroundColor="#63c3d0" class="m6"></label>
<label text="second" width="70%" backgroundColor="#63c3d0" class="m6"></label>
<label text="third" width="70%" backgroundColor="#63c3d0" class="m6"></label>
</flexboxLayout>
{:else }
<stackLayout flexWrap="wrap" class="v-a-c t-a-c">
<textField bind:text="{personName}" class="m6 new-person" ></textField>
<button text="add new value" on:tap="{createNewPlayer}" />
</stackLayout>
{/if}
So why it doesn't work? What am I doing wrong?

Does vee-validate work with third-party UI components, e.g. of Primevue?

I am using vee-validate v4.0, vue's (v3) components with TypeScript and UI components from Primevue and Ionic. Validation on simple input fields works fine:
<template>
...
<Field
v-slot="{ field }"
v-model="username"
:rules="isRequired"
name="username"
>
<IonInput
v-bind="field"
type="text"
/>
</Field>
<ErrorMessage
name="username"
class="error"
/>
...
</template>
<script lang="ts">
...
methods: {
isRequired (value: string) {
if (!value) {
return 'This field is required'
}
return true
}
}
...
</script>
Applying the same to Primevue's Dropdown element fails:
<Field
v-slot="{ field }"
v-model="campaign"
name="campaign"
:rules="isRequired"
>
<Dropdown
:options="campaigns"
option-value="id"
option-label="name"
placeholder="Choose a campaign"
v-bind="field"
/>
</Field>
<ErrorMessage
name="campaign"
class="error"
/>
Validation works as expected, but opening the Dropdown leads to error messages:
Do you know how this can be solved? Is there an example how vee-validate works with more complex fields like dropdown or multiselect elements?
This can be solved by listening on the input/change events and passing data between <Field> and (in this special case Primevue's) <Dropdown> as follows:
<Form v-slot="{ errors }" #submit="saveAndProceed()">
...
<Field
v-slot="{ field }"
v-model="campaign"
name="campaign"
value="value"
:rules="isRequired"
>
<Dropdown
:options="campaigns"
option-value="id"
option-label="name"
placeholder="Choose a campaign"
:model-value="field.value"
:class="{ 'p-invalid': errors.campaign }"
#input="field.onInput.forEach((fn) => fn($event.value))"
#change="field.onChange.forEach((fn) => fn($event.value))"
/>
<ErrorMessage
name="campaign"
class="error"
/>
</Field>
...
</Form>
Compare also with the following references for other events (onBlur etc.):
Vee-validate's Field reference
E.g., Primevue's Dropdown events
You need to add #update:modelValue="handleChange" to your dropdown:
<Field
v-slot="{ field, handleChange }"
v-model="campaign"
name="campaign"
:rules="isRequired"
>
<Dropdown
:options="campaigns"
option-value="id"
option-label="name"
placeholder="Choose a campaign"
v-bind="field"
#update:modelValue="handleChange"
/>
</Field>
<ErrorMessage
name="campaign"
class="error"
/>
<div class="col-6">
<Field
v-slot="{ field,handleChange }"
v-model="brand_name"
name="brand_name"
>
<div class="p-col-6">
<div class="p-inputgroup">
<Dropdown
:options="brands"
optionLabel="name"
optionValue="code"
:model-value="field.value"
placeholder="Select car brand"
#update:modelValue="handleChange"
/>
</div>
</div>
</Field>
</div>

Change line color of text field when focused using RadDataForm in nativescript

I'm using telerik pro ui library in nativescript, I struggled in changing the bottom line color of text field when focused to be appropriate to design
I want to change the blue default color of line
The text field currently rendered as shown in the following image
The code of template view is
<GridLayout rows="100, *" row="1" class="m-x-10 m-t-75">
<RadDataForm #loginFormElement [source]="loginForm" [isReadOnly]="isLoading" row="0" class="fa">
<TKEntityProperty tkDataFormProperty name="email" displayName="" hintText="example#gmail.com" imageResource="res://fa_user" required="true"
index="0">
<TKPropertyEditor class="fa" tkEntityPropertyEditor type="Email">
<TKPropertyEditorStyle tkPropertyEditorStyle labelHidden="true" labelWidth="0"></TKPropertyEditorStyle>
</TKPropertyEditor>
<TKNonEmptyValidator tkEntityPropertyValidators errorMessage="البريد الالكتروني مطلوب"></TKNonEmptyValidator>
<TKEmailValidator tkEntityPropertyValidators errorMessage="البريد الالكتروني غير صحيح"></TKEmailValidator>
</TKEntityProperty>
<TKEntityProperty tkDataFormProperty name="password" displayName="" hintText="كلمة المرور" required="true" index="1">
<TKPropertyEditor tkEntityPropertyEditor type="Password">
<TKPropertyEditorStyle class="fa" tkPropertyEditorStyle labelHidden="false" labelTextSize="18" labelFontName="FontAwesome"
labelPosition="Left" labelWidth="30" labelTextColor="#999"></TKPropertyEditorStyle>
</TKPropertyEditor>
<TKNonEmptyValidator tkEntityPropertyValidators errorMessage="كلمة المرور مطلوبة"></TKNonEmptyValidator>
</TKEntityProperty>
</RadDataForm>
<Button class="form-submit-button bg-light-green m-y-25 m-l-5 m-r-5" [text]="'تسجيل دخول'" (tap)="onSigninButtonTap()" row="1"></Button>
</GridLayout>
The blue color is default accent color for all Android input fields. You can go to:
App_Resources -> Android -> values -> colors.xml file and change ns_accent to your color. You have other colors you can customize as well.
At the moment I'm trying to figure it out how to change font color in raddataform input field.

JSP kendo grid EDIT /ADD Handle ERROR response from spring rest Kendo UI v2015.3.1111

Trying Kendo UI JSP editable grid. Grid is working with few problems.
(Version : Kendo UI v2015.3.1111 )
Export: Even with allPages="allPages", its exporting only current
page.
After CREATE, GRID is not updated with server response which has user createDate. Same with Update, grid not updated with update date
even though the updated user object is passed.
Grid shows user added even if it failed in the backend. How to handle error response for create /update and show the failed message ?
Any help greatly appreciated.
Controller create part:
#RequestMapping(value = "/user/create", method = RequestMethod.POST)
public #ResponseBody User create(#RequestBody Map<String, Object> model) {
log.debug("create");
User target = new User();
target.setUserName((String)model.get("UserName"));
target.setFirstName((String)model.get("firstName"));
target.setLastName((String)model.get("lastName"));
target.setOpenDate(getDateFromStr((String)model.get("openDate")));
target.setEditDate(getDateFromStr((String)model.get("editDate")));
User user = userDao.createUser(target);
log.info("user"+user.getUserId()+user.getOpenDate());
return user;
}
JSP PART:
<c:url value="/user/create" var="createUrl" />
<c:url value="/user/read" var="readUrl" />
<c:url value="/user/update" var="updateUrl" />
<c:url value="/user/destroy" var="destroyUrl" />
<c:url value="/user/saveexcel" var="saveExcelUrl" />
<c:url value="/user/savepdf" var="savePdfUrl" />
<kendo:grid name="grid" pageable="true" sortable="true" height="750px" filterable="true">
<kendo:grid-scrollable/>
<kendo:grid-pdf fileName="KendoUIGridExport.pdf" allPages="allPages" proxyURL="${savePdfUrl}"/>
<kendo:grid-excel fileName="KendoUIGridExport.xlsx" allPages="allPages" proxyURL="${saveExcelUrl}" />
<kendo:grid-editable mode="popup" confirmation="Are you sure you want to remove this item?"/>
<kendo:grid-toolbar>
<kendo:grid-toolbarItem name="create"/>
<kendo:grid-toolbarItem name="excel"/>
<kendo:grid-toolbarItem name="pdf"/>
</kendo:grid-toolbar>
<kendo:grid-columns>
<kendo:grid-column title="User Name" field="userName" width="120px"/>
<kendo:grid-column title="First Name" field="firstName" width="120px" />
<kendo:grid-column title="Last Name" field="lastName" width="120px" />
<kendo:grid-column title="Open Date" field="openDate" width="120px" format="{0:MM/dd/yyyy}" />
<kendo:grid-column title="Edit Date" field="editDate" width="120px" format="{0:MM/dd/yyyy}" />
<kendo:grid-column title=" " width="150px">
<kendo:grid-column-command>
<kendo:grid-column-commandItem name="edit" />
<kendo:grid-column-commandItem name="destroy" />
</kendo:grid-column-command>
</kendo:grid-column>
</kendo:grid-columns>
<kendo:dataSource pageSize="10" serverPaging="false" serverSorting="false" serverFiltering="false" serverGrouping="false" >
<kendo:dataSource-transport>
<kendo:dataSource-transport-create url="${createUrl}" type="POST" dataType="json" contentType="application/json"/>
<kendo:dataSource-transport-read url="${readUrl}" type="POST" dataType="json" contentType="application/json"/>
<kendo:dataSource-transport-update url="${updateUrl}" type="POST" dataType="json" contentType="application/json" />
<kendo:dataSource-transport-destroy url="${destroyUrl}" type="POST" dataType="json" contentType="application/json" />
<kendo:dataSource-transport-parameterMap>
<script>
function parameterMap(options,type) {
return JSON.stringify(options);
}
</script>
</kendo:dataSource-transport-parameterMap>
</kendo:dataSource-transport>
<kendo:dataSource-schema>
<kendo:dataSource-schema-model id="userId">
<kendo:dataSource-schema-model-fields>
<kendo:dataSource-schema-model-field name="userName" type="string" >
<kendo:dataSource-schema-model-field-validation required="true" />
</kendo:dataSource-schema-model-field>
<kendo:dataSource-schema-model-field name="firstName" type="string">
<kendo:dataSource-schema-model-field-validation required="true" />
</kendo:dataSource-schema-model-field>
<kendo:dataSource-schema-model-field name="lastName" type="string">
<kendo:dataSource-schema-model-field-validation required="true" />
</kendo:dataSource-schema-model-field>
<kendo:dataSource-schema-model-field name="openDate" type="date" editable="false" />
<kendo:dataSource-schema-model-field name="editDate" type="date" editable="false"/>
</kendo:dataSource-schema-model-fields>
</kendo:dataSource-schema-model>
</kendo:dataSource-schema>
</kendo:dataSource>
</kendo:grid>
Resolved myself: For pdf, allPages="true" works.
Grid refresh: FOR requestEnd event
function onRequestEnd(e) {
if (e.type == "create") {
e.sender.read();
}
else if (e.type == "update") {
e.sender.read();
}
}

Zk how to reach included .zul page component by id?

I can't reach component by id in the included .zul page. I have one main.zul with a controller and I need to get a component in included zul page through the java controller class, but it returns null.
I know the included method creates new id space but is there any way to get this component?
UPDATE
Here is my code:
the main zul page
<?page title="DealerVizard.zul"?>
<?page id="main" ?>
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="./Dealer" ?>
<zk>
<style src="/resources/css/default.css" />
<window id="Dealer" class="index"
apply="com.i2i.prm.controller.IndexController">
<div class="content" width="100%">
<tabbox id="tb" forward="onSelect=onSelect">
<tabs id="tabs">
<tab id="info" label="INFO" />
<tab id="create" label="CREATE" />
<tab id="edit" label="EDIT" />
<tab id="test" label="TEST PANEL(LIST BOX)" />
</tabs>
<tabpanels>
<tabpanel id="DealerInfo">
<include id="DealerInfoContent"
src="View/Dealer/DealerInfo.zul" />
</tabpanel>
<tabpanel id="DealerCreate">
<include id="DealerCreateContent"
src="View/Dealer/DealerCreate.zul" />
</tabpanel>
<tabpanel id="DealerEdit">
<include id="DealerEditContent"
src="View/Dealer/DealerEdit.zul" />
</tabpanel>
<tabpanel id="PagingListBox">
<include id="PagingListBoxContent" // Included here
src="View/TEST/PagingListBox.zul" />
</tabpanel>
</tabpanels>
</tabbox>
</div>
</window>
</zk>
PagingListBox.zul (Included page)
<?page id="list" ?>
<zk>
<grid width="100%">
<columns>
<column label="" />
</columns>
<rows>
<row>
<listbox id="listModel" width="100%" height="100%"
visible="true" span="true" pagingPosition="top" rows="20"
selectedItem="#{DealerController.selected}"
model="#{DealerController.userList}"
forward="onSelect=//main/Dealer.onSelect">
<auxhead>
<auxheader colspan="1">
<textbox
value="#{DealerController.searchUser.name}" maxlength="9"
id="searchCO_ID" forward="onChanging=//main/Dealer.onSearch"
width="100%">
</textbox>
</auxheader>
<auxheader colspan="1">
<textbox
value="#{DealerController.searchUser.surname}" maxlength="21"
id="searchMSISDN" forward="onChanging=//main/Dealer.onSearch"
width="100%">
</textbox>
</auxheader>
<auxheader colspan="1">
</auxheader>
</auxhead>
<listhead>
<listheader label="Name"
sort="auto(UPPER(name))" />
<listheader label="Surname"
sort="auto(UPPER(surname))" />
<listheader label="Delete ?" />
</listhead>
<listitem self="#{each=USERLIST}">
<listcell>
<label value="#{USERLIST.user.name}" />
<textbox
value="#{DealerController.tmpUser.name}" visible="false" />
</listcell>
<listcell>
<label value="#{USERLIST.user.surname}" />
<textbox
value="#{DealerController.tmpUser.surname}" visible="false" />
</listcell>
<listcell>
<button label="Update"
forward="onClick=//main/Dealer.onUpdate" visible="false" />
<button image="icons/edit-delete.png"
label="Delete" forward="onClick=//main/Dealer.onDelete"
width="100%" disabled="true" />
<button label="Save"
forward="onClick=//main/Dealer.onSave" visible="false" />
<button label="Cancel"
forward="onClick=//main/Dealer.onCancel" visible="false" />
</listcell>
</listitem>
</listbox>
<paging id="pagingData" pageSize="20" />
</row>
</rows>
</grid>
</zk>
IndexCOntroller.java
public class IndexController extends GenericForwardComposer {
private List<User> userList = new ArrayList<User>() ;
AnnotateDataBinder binder;
Tabbox tb;
Window Dealer;
private int pageCount=0;
#Override
public void doAfterCompose(Component comp) throws Exception {
// TODO Auto-generated method stub
super.doAfterCompose(comp);
comp.setVariable(comp.getId() + "Controller", this, true);
binder = (AnnotateDataBinder) Dealer.getVariable("binder", true);
System.out.println(Path.getComponent("//list/listModel"));
}
public IndexController() {
// TODO Auto-generated constructor stub
}
}
Normally I wouldn't recommend using Path.getComponent() way to access other components as your application code becomes tightly coupled with your component structure in your view page.
In your case you simplest way is to use AbstractComponent#getFellow(String compId) method so for eg.
Include inc = (Include) Dealer.getFellow("PagingListBoxContent");
Listbox listModel = (Listbox) inc.getFellow("listModel");
System.out.println(listModel);
So in future even if you insert any other component in your ZUML page before your listbox your code will still work.
UPDATE: BTW there was an interesting blogpost on this very topic on ZK blog recently
if your include have id, you can use dollar sign to get the inner components
<zk>
<include id="inc" src="test.zul />
</zk>
test.zul
<zk>
<label id="lab1" value="test1" />
</zk>
you can use "inc$lab1" get the label in test.zul
You can access any component in any other id space using zscript or java. if it is on the same page, but different window then (component B in window A):
Path.getComponent("/A/B");
if it is on a different page then (component B in window A on page P):
Path.getComponent("//P/A/B");
You can find documentation here: http://books.zkoss.org/wiki/ZK%20Developer%27s%20Reference/UI%20Composing/ID%20Space
You can add in your IndexController.java:
...
private Include DealerInfoContent;
...
this way you can access the included component within the parent composer.
(I would suggest to use camelCase ids for it, though).

Resources