How we can return multiple table schema in getSchema method of custom looker - google-data-studio

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
]
}
]
}
}

Related

Using multiple model associations with bindings

I am using ExtJS 6.x with three models:
Ext.define('Admin.model.Patient', {
extend: 'Ext.data.Model',
requires: [
'Ext.data.proxy.Rest',
'Ext.data.schema.Association'
],
fields: [
{ name: 'id', type: 'string' },
{ name: 'mrn', type: 'string' },
{ name: 'birth_date', type: 'date', format: 'Y-m-d' },
{ name: 'sex', type: 'string' },
{ name: 'first_name', type: 'string' },
{ name: 'last_name', type: 'string' },
],
style: {
'font-size': '22px',
'color':'red'
},
proxy: {
type: 'ajax',
url: remote.url.patient,
reader: {
type: 'json',
rootProperty: ''
}
}
});
Ext.define('Admin.model.LabResultGroup', {
extend: 'Ext.data.Model',
idProperty: 'id',
fields: [
{ name: 'test_code', type: 'string' },
{ name: 'test_name', type: 'string' },
{
name: 'patient_id',
type: 'string',
reference: {
parent: 'Patient',
inverse: 'lab_results',
autoLoad: false
}
}
],
proxy: {
type: 'ajax',
url: remote.url.labsgroup,
reader: {
type: 'json',
rootProperty: ''
}
});
and
Ext.define('Admin.model.LabResult', {
extend: 'Ext.data.Model',
idProperty: 'id',
fields: [
{ name: 'test_code', type: 'string' },
{ name: 'test_name', type: 'string' },
{ name: 'test_code_system', type: 'string' },
{ name: 'result_value', type: 'string' },
{ name: 'result_value_num', type: 'string' },
{ name: 'collection_datetime', type: 'date', format: 'Y-m-d' },
{ name: 'result_datetime', type: 'date', format: 'Y-m-d' },
{
name: 'lab_id',
type: 'string',
reference: {
parent: 'LabResultGroup',
inverse: 'lab_group',
autoLoad: false
}
}
],
proxy: {
type: 'ajax',
url: remote.url.labs,
reader: {
type: 'json',
rootProperty: ''
}
}
});
I can access the association between LabResultGroup and Patient just fine (between two comboboxes using bindings), but when I try accessing the association between LabResult and LabResultGroup, it does not register.
I will post a Fiddle in due course to exhibit the behavior I am encountering. Is there anything that would prevent associations across models like this?
It actually worked! For some odd reason the parent name in the association on my LabResult model got mucked up. Corrected that, and my association bindings are firing as expected.
(Also, there was a minor problem with the API endpoint I was accessing. I had to add another condition for the property on which it was filtering. Details, shmetails)
Moral of the story: Names are important! Happy Friday peeps! Ha! Ha!

Wrap some field in div in angular-formly

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'
}
}
}]
];

load Data from local store

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

1 to many model association

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/

Sencha Touch not reading data

I have my model as this:
Ext.define("NotesApp.model.Note", {
extend: "Ext.data.Model",
config: {
idProperty: 'id',
fields: [
{ name: 'id', type: 'int' },
{ name: 'dateCreated', type: 'date', dateFormat: 'c' },
{ name: 'question', type: 'string' },
{ name: 'answer', type: 'string' },
{ name: 'type', type: 'int'},
{ name: 'author', type: 'int'}
],
validations: [
{ type: 'presence', field: 'id' },
{ type: 'presence', field: 'dateCreated' },
{ type: 'presence', field: 'question', message: 'Please enter a question for this card.' }
]
}
});
and my server page (qa.php) outputs this:
{"results":[{"id":"1","dateCreated":"2012-05-01","question":"asdf?","answer":"fdsa","type":"0","author":"0"},{"id":"2","dateCreated":"2012-05-01","question":"qwer?","answer":"rewq","type":"0","author":"0"}]}
and this is my code in the store:
Ext.define("NotesApp.store.Online", {
extend: "Ext.data.Store",
config: {
model: 'NotesApp.model.Note',
storeId: 'Online',
proxy: {
type: 'jsonp',
url: 'http://xxxxxxxx.com/qa.php',
reader: {
type: 'json',
rootProperty: 'results'
}
},
autoLoad: false,
listeners: {
load: function() {
console.log("updating");
Ext.getStore('Notes').getProxy().clear();
console.log("updating1");
// Loop through records and fill the offline store
this.each(function(record) {
console.log("updating2");
Ext.getStore('Notes').add(record.data);
});
// Sync the offline store
Ext.getStore('Notes').sync();
console.log("updating3");
// Remove data from online store
this.removeAll();
console.log("updated");
}
},
fields: [
{
name: 'id'
},
{
name: 'dateCreated'
},
{
name: 'question'
},
{
name: 'answer'
},
{
name: 'type'
},
{
name: 'author'
}
]
}
});
But when I called Ext.getStore('Online').load(), the console showed "updating", "updating1", and "updating3" but not any "updating2", ie. no records were found. I wonder where the mistake is? Is there a way to output the jsonstring that's read in?
This is a different scope
listeners: {
load: function() {
console.log("updating");
Ext.getStore('Notes').getProxy().clear();
console.log("updating1");
// Loop through records and fill the offline store
this.each(function(record) {
console.log("updating2");
Ext.getStore('Notes').add(record.data);
});
// Sync the offline store
Ext.getStore('Notes').sync();
console.log("updating3");
// Remove data from online store
this.removeAll();
console.log("updated");
},
this//adds scope
or
listeners: {
load: function(store,record,options) {
console.log("updating");
Ext.getStore('Notes').getProxy().clear();
console.log("updating1");
// Loop through records and fill the offline store
store.each(function(record) {
console.log("record"); //wahei records!
Ext.getStore('Notes').add(record.data);
});
// Sync the offline store
Ext.getStore('Notes').sync();
console.log("updating3");
// Remove data from online store
this.removeAll();
console.log("updated");
}

Resources