I want to use dataview to render the following hierarchy data:
[{
id: 1,
name: 'Parent #1',
children: [ { id: 11, name: 'Child 1.1' }, { id: 12, name: 'Child 1.2' }]
},
{
id: 1,
name: 'Parent #1',
children: [ { id: 21, name: 'Child 2.1' }, { id: 22, name: 'Child 2.2' }]
}]
in the form of:
Parent #1 <- div with class = x-title
Child 1.1 <- div with class = x-list-item
Child 1.2
Parent #2
Child 2.1
Child 2.2
My dataview tpl configured like this:
...
trackOver: true,
tpl: new Ext.XTemplate(
'<tpl for=".">',
'<div class="x-title">{name}</div>',
'<tpl for="children">',
'<div class="x-list-item">{name}</div>',
'</tpl>',
'</tpl>'
),
...
Here is the problem:
- itemSelector: ‘x-list-item’ not working Cannot read property ‘internalId’ of undefined
- itemSelector: ‘x-title’ work!
I wonder if it possible at all to support itemSelector which point to children element instead of root level?
It is possible after extending DataView a bit.
Example code:
Working sample: http://jsfiddle.net/fU9De/
But it’s easy to achieve without modifying
DataViewby only changing data layout in that way children are separated records. For example:Then you can change template to:
and you’ll have working selection out-of-box.