reading data from nested json - extjs4

Its same regarding my previous post. This is the changed json I am getting from the server.
{"property":[{"#length":"10","#mandatory":"true","#type":"String","#label":"Description","#id":"desc"},{"#mandatory":"false","#type":"Number","#label":"Code","#id":"code"},{"#mandatory":"true","#type":"Boolean","#label":"Check","#id":"check"},{"#mandatory":"true","#type":"DateField","#label":"Date","#id":"date"},{"#mandatory":"true","#type":"List","#label":"Types","#id":"types","options":[{"#value":"eee"},{"#value":"fff"}]}]}
I want to render the options array of Types in a combo-box.This is the model.
Ext.define('Property', {
extend : 'Ext.data.Model',
fields : [ {
name : 'id',
mapping : '#id'
}, {
name : 'label',
mapping : '#label'
}, {
name : 'type',
mapping : '#type'
}, {
name : 'mandatory',
mapping : '#mandatory'
}, {
name : 'length',
mapping : '#length'
} ],
// {name : 'values', mapping : 'options[0].#value'}], didnt work
hasMany : {
model : 'Options',
name : 'options'
}
});
Ext.define('Options', {
extend : 'Ext.data.Model',
// reader : {
type : 'json',
root : 'options'
},
fields : [ {
name : 'value1',
mapping : '#value'
} ],
associations : [ {
type : 'belongsTo',
model : 'Property'
} ]
});
Unable to find what is going wrong. Can someone suggest me the proper way of doing it?

I think you should look into the "associations" concept in the models, and use the hasMany/belongs to relationships. IMHO, it would make it easier and cleaner code, in the same way more usefull later in the code when you will need to use the data you're trying to set.
FOr more info about association please refer to this great link in sencha docs
HTH!

How are you configuring your combo store? If your data was fetched already you can just set the data for the combo by accessing raw data that was returned to the store.

Related

How to look for more than one element in an embedded array in MongoDb

I have a mongodb query: (Give me settings where account='test')
db.collection_name.find({"account" : "test1"}, {settings : 1}).pretty();
where I get the following output:
{
"_id" : ObjectId("49830ede4bz08bc0b495f123"),
"settings" : {
"clusterData" : {
"us-south-1" : "cluster1",
"us-east-1" : "cluster2"
},
},
What I'm looking for now, is to give me the account where the clusterData has more than 1 element in its array.
I'm only interested in listing those accounts with (2) or more elements.
I've tried this:
db.collection_name.find({'settings.clusterData.1': {$exists: true}}, {account : 1}).pretty();
Its not returning any results. Is my query correct? Is there another way to do this?
The reason that it isn't working is that your clusterdata is an object, not an array. I would suggest changing your data to be an array of clusters with two properties like below, then it will work.
{
"_id" : ObjectId("49830ede4bz08bc0b495f123"),
"settings" : {
"clusterData" : [
{
name : "cluster1",
location : "us-south-1"
},
{
name : "cluster2",
location : "us-east-1"
}
]
}
}

Getting null value output after Transformation using Mule Datamapper

I have a transformer component in Mule, that transform xml to json. But output json has null Object/Array
eg :-
"PublicRecord" : {
"PostalAddress" : {
"Municipality" : [ ]
}
},
"RegistrySearch" : {
"PostalAddress" : {
"Municipality" : [ ]
},
"License" : {
"LicenseAuthorityAddress" : {
"Municipality" : [ ]
}
}
},
How can I remove this null object in Transformation ?
You probably have a cardinality problem. In datamapper you iterate over the input to generate output. Somehow you are performing an iteration that is not necessary. Review at the center-top of your dialog, the element mapping (you need to click on modify) and play with the nested mappings.

Obtaining Object IDs for Schedule States in Rally

I have set up a "checkbox group" with the five schedule states in our organization's workspace. I would like to query using the Lookback API with the selected schedule states as filters. Since the LBAPI is driven by ObjectIDs, I need to pass in the ID representations of the schedule states, rather than their names. Is there a quick way to get these IDs so I can relate them to the checkbox entries?
Lookback API will accept string-valued ScheduleStates as query arguments. Thus the following query:
{
find: {
_TypeHierarchy: "HierarchicalRequirement",
"ScheduleState": "In-Progress",
__At:"current"
}
}
Works correctly for me. If you want/need OIDs though, and add &fields=true to the end of your REST query URL, you'll notice the following information coming back:
GeneratedQuery: {
{ "fields" : true,
"find" : { "$and" : [ { "_ValidFrom" : { "$lte" : "2013-04-18T20:00:25.751Z" },
"_ValidTo" : { "$gt" : "2013-04-18T20:00:25.751Z" }
} ],
"ScheduleState" : { "$in" : [ 2890498684 ] },
"_TypeHierarchy" : { "$in" : [ -51038,
2890498773,
10487547445
] },
"_ValidFrom" : { "$lte" : "2013-04-18T20:00:25.751Z" }
},
"limit" : 10,
"skip" : 0
}
}
You'll notice the ScheduleState OID here:
"ScheduleState" : { "$in" : [ 2890498684 ] }
So you could run a couple of sample queries on different ScheduleStates and find their corresponding OIDs.

Nested List not loading in sencha

I am trying to load a Nested list onto my Sencha app. The problem is I am not familiar with it and i am not sure if the json file i am using is correct.
[
{
"text":[
{
"text":"1.1.1",
"leaf":true
}],
"text":[
{
"text":"1.1.1",
"leaf":true
}
]
}
]
This is my store code
//Defining the store for the Nested List
Ext.define('InfoImage.store.nestedListStore', {
extend: 'Ext.data.TreeStore',
requires: 'InfoImage.model.nestedListModel',
id:'nestedListStore',
config:{
//Calling the required model for the Work Item List
model : 'InfoImage.model.nestedListModel',
//Defining the proxy for the Work Item List to pull the data for the List
proxy : {
type : 'ajax',
url : 'app/model/data/list.json',
reader: {
type: 'json',
root: 'items'
}
},
autoLoad: true
}
});
and my main code is
Ext.define("InfoImage.view.nestedList", {
extend:'Ext.NestedList',
xtype:'nestedList',
id:'nestedList',
config:{
fullscreen:'true',
title:'Nested List',
xtype:'nestedList',
//displayField : 'text',
html:'Nested List on its way!!!',
store:'nestedListStore'
//itemTpl:'{text}'
}
});
The output thats displayed is [object object]. I dont know what is missing. ANy help is appreciated.
Firstly, your Json is a VALID json. Always check for valid json by pasting the json on jsonlint.com
Secondly, I see that you have commented out the
displayField:'text'
property. If you don't provide the displayField to the nestedlist, it won't come to know, which items from the data store to show in the list.
Probably, that's why you are getting the [object Object] as your o/p in the list.
Uncomment the above line and check.
It seems that your JSON cannot work with Ext.NestedList because text is a field of your Model and it should not be declared as rootProperty in your JSON file.
Firstly, assume that you have this model definition:
Ext.define('ListItem', {
extend: 'Ext.data.Model',
config: {
fields: ['text']
}
});
According to your data, your JSON file should look like this:
items: [
{
text: '1.1',
items: [
{ text: '1.1.1', leaf: true },
{ text: '1.1.2', leaf: true }
]
}
]
You have to add this config to your Store as well defaultRootProperty: 'items'

Sencha Touch selectfield cannot display value from datastore

I'm trying to load a store into a Select field in sencha touch 2.0 but got a strange proble:
For following code:
{
xtype : 'list',
store : 'Docbases',
itemTpl : 'Hello {docbase}!'
}, {
xtype : 'selectfield',
label : 'Docbase',
id : 'docbase',
store : 'Docbases',
displayField : 'docbase',
valueField : 'docbase',
placeHolder : 'Select a Value'
}
The list component can display well, while selectfield cannot display the value. When click on that selectfield, I got a console error:
Uncaught TypeError: Cannot call method 'get' of null
My Store is declared as:
Ext.define('FDMobileClient.store.Docbases', {
extend : 'Ext.data.Store',
requires : ['FDMobileClient.model.Docbase'],
model : 'FDMobileClient.model.Docbase',
autoLoad : true,
proxy : {
type : 'ajax',
url : '/MobileInternalProject/mobile/getDocbaseList.action',
reader : {
type : 'json',
root : 'docbases'
}
},
});
Does anyone have any ideas what I'm doing wrong :(
I'm appreciated all of your help. Thanks
Long
Your store seems fine to me. That's what I did to get is sorted:
in your view config:
config: {
...
docStore : null
...
},
in your view init:
initialize: function() {
...
docStore = Ext.create('FDMobileClient.store.Docbases');
...
},
finally the code for your selectfield
{
xtype : 'list',
store : 'Docbases',
itemTpl : 'Hello {docbase}!'
}, {
xtype : 'selectfield',
label : 'Docbase',
id : 'docbase',
store : docStore, //NOTE: no quotes!
displayField : 'docbase',
valueField : 'docbase',
placeHolder : 'Select a Value'
}
It worked for me, it should be OK for you too. Good luck, Alex
You should give your store an ID and use this identifier when referring to the store:
Ext.define('FDMobileClient.store.Docbases', {
extend : 'Ext.data.Store',
requires : ['FDMobileClient.model.Docbase'],
model : 'FDMobileClient.model.Docbase',
id : 'DocbaseStore'
...
}
{
...
store : 'DocbaseStore',
displayField : 'docbase',
...
}