PDA

View Full Version : Ext.data.store with json



praveen_pkc
9 Mar 2012, 6:21 AM
Hi
I am trying to use grid with json. My json string looks something like

{ "name":"zys", model : { "address":"add", diskVolumeInfoList: {{"flags":13}} }
}

I created the store below to access flags attribute of diskVolumeInfoList

Ext.define (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext-method-define)('User', { extend: 'Ext.data.Model (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.data.Model)', fields: [ {name: 'model.diskVolumeInfoList.flags', type: 'string'} ] });In the jsonReader , i don't want to set the root attribute because i want to use parent attributes like "name"

The above code "model.diskVolumeInfoList.flags" do not work .
Please suggest.

mitchellsimoens
9 Mar 2012, 11:07 AM
Is that 100% what your JSON looks like?

aacoro
9 Mar 2012, 12:26 PM
Hi
I am trying to use grid with json. My json string looks something like

{ "name":"zys", model : { "address":"add", diskVolumeInfoList: {{"flags":13}} }
}

I created the store below to access flags attribute of diskVolumeInfoList

Ext.define (http://docs.sencha.com/ext-js/4-0/#!/api/Ext-method-define)('User', { extend: 'Ext.data.Model (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Model)', fields: [ {name: 'model.diskVolumeInfoList.flags', type: 'string'} ] });In the jsonReader , i don't want to set the root attribute because i want to use parent attributes like "name"

The above code "model.diskVolumeInfoList.flags" do not work .
Please suggest.

Use http://jsonlint.com/ to verify your json! It is not valid.

praveen_pkc
9 Mar 2012, 10:04 PM
My point was , how do we access child attribute values with grid ? In the gridColumn can i use "model.diskVolumeInfoList.flags" ?

The actuall json string is :

{"diskPoolName":"dp_C_Drive","diskVolumnListByDiskPoolKey":"success","model":{"NBDGUp":true,"advancedDisk":true,"availableSpace":11433222144,"capacityManagedRetentionSupported":true,"comment":"This is on C:\\ Drive","diskVolumeInfoList":[{"flags":14,"id":"C:\\","independentMirror":false,"localCacheOn":0,"mediaServerName":null,"mirror":false,"name":"C:\\","networkOn":0,"operation":0,"otherProperties":null,"primary":false,"rawSize":42842714112,"replicationSource":false,"replicationTarget":false,"replicationTargetSTS":null,"snapShotEnabled":false,"state":0,"storageServerName":null,"storageServerType":null,"tdOn":0,"type":5,"usableSize":11433222144,"volumeDeleted":false}],"flags":515527,"highWaterMark":98,"inconsistentSnapshotMirror":false,"independentCopy":false,"key":{"diskPoolName":"dp_C_Drive","serverType":"AdvancedDisk"},"lifeCycleSupported":true,"lowWaterMark":80,"maxIOStreams":-1,"mediaServerList":["v-061604a.punin.sen.symantec.com"],"mirror":false,"name":"dp_C_Drive","openStorageType":true,"percentageFull":73.3135,"primary":false,"propertiesInconsistent":false,"propertyList":{"DSM::totalPhysicalCapacity":"42842714112","DSM::usedPhysicalSpace":"0","DSM::totalCapacity":"42842714112","DSM::flagsExt":"0","DSM::imported":"Yes","DSM::lowWaterMark":"80","DSM::createdTime":"1331178024","DSM::systemTag":"Created by NetBackup","DG_TOTAL_SZ":"42842714112","DSM::usedSpace":"0","DG_FREE_SZ":"11433222144","DSM::state":"2","DSM::userTag":"This is on C:\\ Drive","DG_USED_SZ":"31409491968","DSM::master":"v-061604a.punin.sen.symantec.com","DSM::majorEventSyncToken":"1331301581","DSM::highWaterMark":"98","DSM::flags":"515527","DSM::lastModifiedTime":"0","DSM::minorEventSyncToken":"771781","DSM::servertype":"AdvancedDisk","DSM::maxIOStreams":"-1","DSM::fileSystemCardinal":"0"},"pureDisk":false,"rawSize":42842714112,"replicationPropertiesChanged":false,"replicationSource":false,"replicationTarget":false,"replicationTopologyChanged":false,"replicationVolumeDeleted":false,"serverType":"AdvancedDisk","sharedDiskType":false,"snapShotEnabled":false,"status":2,"statusString":"Up","storageServerList":[{"cloudEnabled":false,"cloudProviderName":"","cryptType":false,"key":{"stsName":"v-061604a.punin.sen.symantec.com","stsType":"AdvancedDisk"},"mediaServerList":[""],"snapshotEnabled":false,"storageServerId":"","storageServerName":"v-061604a.punin.sen.symantec.com","stsType":"AdvancedDisk","stuSubType":0}],"thirdPartyOSType":true,"usableSize":42842714112,"usedSpace":31409491968,"volumeList":["C:\\"]},"serverType":"AdvancedDisk","sessionId":3}

dedoz
10 Mar 2012, 7:23 PM
first check data / associations docs, maybe that can help you
after you define your model with associations so there loading the json you can access the associated data (child data)

theres some ways to access associated data in a grid.
this actually depends on how you set the models
like setting a renderer config (check docs for grid / column - renderer config )
with a function similiar to


renderer : function(value,meta,record){
associatedData = record.getdiskVolumeInfoList()
... do something with associated data ...
return ... something from associated data ... // this will be displayed in the grid respective column
}