Created
September 30, 2016 12:00
-
-
Save rowdyrabouw/c9809479145a8372f26a2cafe7786f83 to your computer and use it in GitHub Desktop.
RadDataForm NativeScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dataFormModule = require("nativescript-telerik-ui-pro/dataform"); | |
import viewModel = require("./person-model"); | |
export function onPageLoaded(args) { | |
var page = args.object; | |
page.bindingContext = new viewModel.PersonViewModel(); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<page loaded="onPageLoaded" | |
xmlns:df="nativescript-telerik-ui-pro/dataform" xmlns="http://www.nativescript.org/tns.xsd"> | |
<df:RadDataForm id="myDataForm" source="{{ person }}"/> | |
<df:RadDataForm.properties> | |
<df:EntityProperty name="name" displayName="Name" index="0"> | |
</df:EntityProperty> | |
<df:EntityProperty name="age" displayName="Age" index="1" > | |
<df:EntityProperty.editor> | |
<df:PropertyEditor type="Number" /> | |
</df:EntityProperty.editor> | |
</df:EntityProperty> | |
<df:EntityProperty name="email" displayName="E-Mail" index="2" > | |
<df:EntityProperty.editor> | |
<df:PropertyEditor type="Email" /> | |
</df:EntityProperty.editor> | |
</df:EntityProperty> | |
<df:EntityProperty name="city" displayName="City" index="3" valuesProvider="New York, Washington, Los Angeles"> | |
<df:EntityProperty.editor> | |
<df:PropertyEditor type="Picker" /> | |
</df:EntityProperty.editor> | |
</df:EntityProperty> | |
<df:EntityProperty name="street" displayName="Street Name" index="4" /> | |
<df:EntityProperty name="streetNumber" displayName="Street Number" index="5" > | |
<df:EntityProperty.editor> | |
<df:PropertyEditor type="Number" /> | |
</df:EntityProperty.editor> | |
</df:EntityProperty> | |
<df:EntityProperty name="password" index="6" > | |
<df:EntityProperty.editor> | |
<df:PropertyEditor type="Password" /> | |
</df:EntityProperty.editor> | |
<df:EntityProperty.validators> | |
<df:MinimumLengthValidator | |
errorMessage="Password must be at least 6 characters long." | |
length="6" /> | |
</df:EntityProperty.validators> | |
</df:EntityProperty> | |
</df:RadDataForm.properties> | |
</page> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class PersonViewModel { | |
private _person: Person; | |
constructor() { | |
} | |
get person() { | |
if (!this._person) { | |
this._person = new Person("Rowdy", 23, "[email protected]", "New York", "5th Avenue", 11, ""); | |
} | |
return this._person; | |
} | |
} | |
export class Person { | |
public name: string; | |
public age: number; | |
public email: string; | |
public city: string; | |
public street: string; | |
public streetNumber: number; | |
public password: string; | |
constructor(name, age, email, city, street, streetNumber, password) { | |
this.name = name; | |
this.age = age; | |
this.email = email; | |
this.city = city; | |
this.street = street; | |
this.streetNumber = streetNumber; | |
this.password = password; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment