How can I wrap some field in div and don't use fieldGroup.I want to all div have class 'left-layout' will wrapped by class 'left-container'
Controller:
vm.fields = [
{
key: 'first',
type: 'input',
className: 'left-layout',
model: vm.model.name,
templateOptions: {
label: 'First Name'
}
},
{
key: 'last',
type: 'input',
model: vm.model.name,
className: 'left-layout',
templateOptions: {
label: 'Last Name'
}
},
{
key: 'email',
type: 'input',
templateOptions: {
label: 'Email Address',
type: 'email'
}
}
];
index.html
<script>
$('.left-layout').wrapAll("<div class='left-container'></div>");
</script>
This is jsbin link: http://jsbin.com/honuxi/edit?html,js,output
Why wouldn't you want to use fieldGroup? That's how you do that. You add the className to the fieldGroup and then wrap the fieldGroup with a wrapper you have pre-defined in the formly config:
.config(function config(formlyConfigProvider) {
formlyConfigProvider.setWrapper({
name: 'left-container',
template: '<div class="left-container">
<formly-transclude></formly-transclude>
</div>'
});
}
vm.fields = [
{
wrapper: 'left-container',
className: 'left-layout',
fieldGroup: [
{
key: 'first',
type: 'input',
model: vm.model.name,
templateOptions: {
label: 'First Name'
}
},
{
key: 'last',
type: 'input',
model: vm.model.name,
templateOptions: {
label: 'Last Name'
}
},
{
key: 'email',
type: 'input',
templateOptions: {
label: 'Email Address',
type: 'email'
}
}
}]
];
Related
I've created method getSchema() for return table fields. Which is working fine.
function getSchema() {
return {
schema: [
{
name: 'order_id',
label: 'Order Id',
dataType: 'STRING',
semantics: {
conceptType: 'DIMENSION'
}
},
{
name: 'currency',
label: 'Currency',
dataType: 'STRING',
semantics: {
conceptType: 'DIMENSION'
}
},
{
name: 'currency_symbol',
label: 'Currency Symbol',
dataType: 'STRING',
semantics: {
conceptType: 'DIMENSION'
}
},
{
name: 'no_of_items',
label: 'Number of Item',
dataType: 'STRING',
semantics: {
conceptType: 'DIMENSION'
}
},
{
name: 'order_date',
label: 'Order Date',
dataType: 'STRING',
semantics: {
conceptType: 'DIMENSION'
}
},
{
name: 'order_status',
label: 'Order Status',
dataType: 'STRING',
semantics: {
conceptType: 'DIMENSION'
}
},
{
name: 'order_value',
label: 'Order Value',
dataType: 'STRING',
semantics: {
conceptType: 'METRIC'
}
},
{
name: 'outlet',
label: 'Outlet',
dataType: 'STRING',
semantics: {
conceptType: 'DIMENSION'
}
},
{
name: 'company_name',
label: 'Company Name',
dataType: 'STRING',
semantics: {
conceptType: 'DIMENSION',
}
},
{
name: 'created_at',
label: 'Created Date',
dataType: 'STRING',
semantics: {
conceptType: 'DIMENSION',
}
},
{
name: 'updated_at',
label: 'Updated Date',
dataType: 'STRING',
semantics: {
conceptType: 'DIMENSION',
}
}
]
}
}
which looks like this
Now I want to return multiple table schema with order table, Like product.
I've tried return multiple schema in getSchema() method but its no working, Getting error during getColumn API call on connector page.
function getSchema() {
return {
schema: [
{
name: 'orders',
label: 'Orders',
field: [
{
name: 'order_id',
label: 'Order Id',
dataType: 'STRING',
semantics: {
conceptType: 'DIMENSION'
}
},
// other columns
]
},
{
name: 'users',
label: 'Users',
field: [
{
name: 'user_id',
label: 'User Id',
dataType: 'STRING',
semantics: {
conceptType: 'DIMENSION'
}
},
// other columns
]
}
]
}
}
I have following code :
var modelForm=[
{
type: 'fieldset',
title: 'Component',
items: [
{
type: 'tabs',
tabs: [
{
title: 'Product',
items: [
'productName',
'releaseVersion',
'distroName',
'stackCategory',
.....
.....
{ type: 'submit', title: 'Update', condition: 'model.id && ! confirmDelete' },
{ type: 'submit', title: 'Create', condition: '!model.id && !confirmDelete' },
{ type: 'button', title: 'Cancel', onClick: 'cancel()', condition: '!confirmDelete' },
{ type: 'button', title: 'Delete', onClick: 'confirmDelete=true' , condition: 'model.id && ! confirmDelete'},
{ type: 'help', helpvalue: '<h1 class=\'\'>Are you sure you want to delete?<h1>', condition: 'confirmDelete' },
{ type: 'button', title: 'Don\'t delete', onClick: 'confirmDelete=false',condition: 'confirmDelete' },
{ type: 'button', title: 'Confirm delete', onClick: 'deleteModel()' , condition: 'confirmDelete'}
Because of using fieldset, all the elements are coming vertically. I want the buttons - Create, Cancel, and Delete described in then end to be in one line.
how can I achieve this?
We solved this for just two buttons ("cancel", "save") by adding the following bootstrap less style:
.schema-form-submit {
display: inline;
}
.schema-form-submit input {
.pull-right;
}
I loop an array inside another array in angular.
fields:
[
{
label: 'First Name',
name: 'firstname',
key: '',
type: 'text',
//fixa requierd i templatesen
required: true
},
{
label: 'Last Name',
name: 'lastname',
key: '',
required: true,
},
{
label: 'Email',
name: 'email',
key: '',
required: true,
type: 'email',
},
{
key: 'test',
type: 'radio',
labels:
[
{
name: 'media',
label: 'Media'
},
{
name: 'frilans',
label: 'Frilans'
}
],
}
],
Whilst looping through field.labels, I want to access it's sibling "key". I tried using $parent scope, but that will include the entire scope. Then angular doesn't know what key it should use.
<div ng-repeat="field in fields">
<div ng-repeat="subfield in field.labels">
<!-- gets you parent's key -->
{{field['key']}}
<!-- you can play around with $index to reach the parent's siblings -->
<!-- just make sure index is in the range though -->
{{fields[$parent.$index - 1]['key']}}
{{fields[$parent.$index + 1]['key']}}
</div>
</div>
I'm facing some diffculties loading specific data records frome local store into app's views.
The store looks like this:
Ext.define('xyz.store.UserDataStore', { extend: 'Ext.data.Store',
requires: [ 'xyz.model.user' ],
config: {
autoLoad: true,
autoSync: true,
model: 'xyz.model.user',
storeId: 'myStore',
proxy: { type: 'localstorage', id: 'id' } } });
The model looks like this:
Ext.define('xyz.model.user', { extend: 'Ext.data.Model',
config: { fields: [ { name: 'token', type: 'string' }, { name: 'title' }, { name: 'login' }, { name: 'facebookId' }, { name: 'firstName', type: 'string' }, { name: 'lastName', type: 'string' }, { name: 'nationality', type: 'string' }, { name: 'birthDay', type: 'string' }, { name: 'phone' }, { name: 'mobile' }, { name: 'street' }, { name: 'city', type: 'string' }, { name: 'zipCode', type: 'int' }, { name: 'willingToTravel' }, { name: 'pictureUrl' }, { name: 'eMail' }, { name: 'publicList' } ] } });
Thank you in advance,
Sabine
I have problems to make an 1 to many model with Sencha Touch 2.
I want to save "persons" and add "todo's" to persons.
These values should be saved at the local storage.
So 1 person can have many todo's.
For this I have 2 models and 2 stores.
Personmodel:
Ext.define("app.model.PersonModel", {
extend: "Ext.data.Model",
config: {
idProperty: 'email',
fields: [
{ name: 'name', type: 'string' },
{ name: 'email', type: 'string' },
],
validations: [
{ type: 'presence', field: 'email' , message: 'Blabla'},
{ type: 'presence', field: 'name' , message: 'Blabla'},
{ type: 'email', field: 'email' , message: 'Blabla'},
]
}
});
TodoModel:
Ext.define("app.model.TodoModel", {
extend: 'Ext.data.Model',
config: {
idProperty: 'todoId',
fields: [
{ name: 'todoId', type: 'int' },
{ name: 'email', type: 'string' },
{ name: 'note', type: 'string' }
],
validations: [
{ type: 'presence', field: 'todoId', message: 'Blabla' },
{ type: 'presence', field: 'email', message: 'Blabla' },
{ type: 'presence', field: 'note', message: 'Blabla' }
]
}
});
PersonStore:
Ext.define("app.store.PersonStore", {
extend: "Ext.data.Store",
requires: "Ext.data.proxy.LocalStorage",
config: {
model: "app.model.PersonModel",
proxy: {
type: 'localstorage',
id: 'todo-app-personstore'
},
sorters: [{ property: 'name', direction: 'ASC'}],
grouper: {
sortProperty: "name",
direction: "ASC",
groupFn: function (record) {
}
}
}
});
TodoStore:
Ext.define("app.store.TodoStore", {
extend: "Ext.data.Store",
requires: "Ext.data.proxy.LocalStorage",
config: {
model: "app.model.TodoModel",
proxy: {
type: 'localstorage',
id: 'todo-app-todostore'
},
sorters: [{ property: 'email', direction: 'ASC'}],
grouper: {
sortProperty: "email",
direction: "ASC",
groupFn: function (record) {
}
}
}
});
I deleted the associations I made in the models because they didn't work at all.
Maybe relevant information: First I want to save a person. Later on I want to save todo's and connect them to a person.
Try Referring below links may helpful to you
http://miamicoder.com/2012/sencha-touch-2-models-hasmany-associations-php-example/
http://appointsolutions.com/2012/07/using-model-associations-in-sencha-touch-2-and-ext-js-4/