PDA

View Full Version : Handling data store with nested array members



geewhizbang
19 Aug 2009, 3:43 PM
We have a field in our data object that has array members.
Can the Data store handle a nested object like this?


KnowledgeBase.Wiki.data = new Ext.data.DirectStore
(
{
proxy: new Ext.data.DirectProxy
(
{
paramsAsHash: false,
directFn: DirectRequest.InitWiki
}
),
autoLoad: false,
directFn: DirectRequest.InitWiki,
paramsAsHash: false,
idProperty: 'WikiID',
fields:
[
{name: 'WikiID', type: 'int'},
{name: 'TemplateID', type: 'int'},
{name: 'Tags', type: '???'},
others ...
],
remoteSort: false
}
);

geewhizbang
19 Aug 2009, 3:57 PM
I accidentally posted this one in the wrong forum.

20 Aug 2009, 1:08 AM
{name: 'Tags', mapping: 'Tags.nodes.nodes.nodes.......'}

geewhizbang
20 Aug 2009, 12:07 PM
I found a mapping example. As usual, the ExtJS documentation app never linked to anything that defined mapping unless I already knew what to look for. So just the key word mapping helped me find some examples.

However I haven't found a node mapping example for ExtJs 3.0.

Given what I know at the moment, the first mapping for WikiContent is a single node, so that feels like it is correct.

However, the Tags mapping is for a node that contains several members with the fields as defined in my code sample, but I suspect that this is not correct.



{name: 'Title', type: 'string'},
{
name: 'WikiContent',
mapping:
[
{name:'TemplateID', type:'int'},
{name:'TemplateTabID', type:'int'},
{name:'Content', type:'string'}
]
},{
name: 'Tags',
mapping:
[

{name:'TagId', type:'int'},
{name:'TagName', type:'string'},
{name:'TagDesc', type:'string'},
{name:'DateCreated', type:'date'},
{name:'DateModified', type:'date'},
{name:'CreatedbyName', type:'string'},
{name:'ModifiedbyName', type:'string'},
{name:'CreatedbyID', type:'int'},
{name:'ModifiedbyID', type:'int'},
{name:'ClientID', type:'int'}
]
},

mschwartz
20 Aug 2009, 12:33 PM
Much ado about nothing.

I send arrays as record field values all the time. You don't need to specify mapping or a field type.

{ name: 'is_an_object' }

consumes:



{
any: 'arbitrary',
object: [ 'foo', 'bar' ]
}

in grid column header:



render: function(value, p, r) {
return r.get('is_an_object').any + ' ' + r.get('is_an_object').object[0];
}


Shows in the grid column:
arbitrary foo

UGA_Zimma
20 Nov 2009, 12:22 PM
Hey mschwartz,

Could you take a look at my post from a few days ago. It sounds like you may be of some assistance.

http://www.extjs.com/forum/showthread.php?t=85624

Thanks in advance,

UGA_Zimma