PDA

View Full Version : [OPEN] RowExpander does not load associated data in XTemplate



wwwreynolds
28 Nov 2013, 7:33 AM
Ext version tested:

Ext 4.2.2

Description:

RowExpander does not load associated data in the XTemplate.

Steps to reproduce the problem:

Run code below (with 'likesToEat' field commented out)

The result that was expected:

Uncomment 'likesToEat' field
The rows expand properly

The result that occurs instead:

When you expand the row in the table, nothing shows

Desired solution:
The problem is in RowExpander.setCmp function, which loads data using getData().

It would be great if RowExpander would have a field (e.g., includeAssociations) that would be passed to getData.



Ext.application({
name: 'Fiddle',

launch: function() {

Ext.define('Simpsons.Model', {
extend: 'Ext.data.Model',
fields: ['name', 'email', 'phone'
// Un-comment to force XTemplate to load the association.
//, 'likesToEat'
],
hasMany: [
{
model: 'Simpsons.Food',
name: 'likesToEat'
}
]
});

Ext.define('Simpsons.Food', {
fields: ['foodName']
});

Ext.create('Ext.data.Store', {
storeId: 'simpsonsStore',
model: 'Simpsons.Model',
data: {
'items': [{
'name': 'Lisa',
"email": "lisa@simpsons.com",
"phone": "555-111-1224",
'likesToEat': [{foodName: 'oranges'}]
}, {
'name': 'Bart',
"email": "bart@simpsons.com",
"phone": "555-222-1234",
'likesToEat': [{foodName: 'homer\'s food'}]
}, {
'name': 'Homer',
"email": "home@simpsons.com",
"phone": "555-222-1244",
'likesToEat': [{foodName: 'donuts'}]
}, {
'name': 'Marge',
"email": "marge@simpsons.com",
"phone": "555-222-1254",
'likesToEat': [{foodName: 'oatmeal'}]
}]
},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});

Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [{
text: 'Name',
dataIndex: 'name'
}, {
text: 'Email',
dataIndex: 'email',
flex: 1
}, {
text: 'Phone',
dataIndex: 'phone'
}],
plugins: [{
ptype: 'rowexpander',
rowBodyTpl: [
'<tpl for="likesToEat">',
'<p>Likes to eat: {foodName}</p>',
'</tpl>'
]
}],
height: 800,
width: 800,
renderTo: Ext.getBody()
});

}
});

Gary Schlosberg
2 Dec 2013, 10:33 AM
It seems to work for me in this fiddle, including when I run it against 4.2.2.
https://fiddle.sencha.com/#fiddle/1t7

I also tried it outside of fiddle and couldn't make it fail. In which browser are you seeing this issue?

wwwreynolds
2 Dec 2013, 12:29 PM
Uncomment 'likesToEat' in the model (line 10 of the fiddle).

When this is commented out, the RowExpander fails to get the associated data for 'likesToEat' b/c it calls getData() (not getData(true)).

Gary Schlosberg
3 Dec 2013, 4:20 PM
Sorry if I'm missing something, but that line isn't commented out in the fiddle (https://fiddle.sencha.com/#fiddle/1t7). The template still populates for me when the row is expanded.

wwwreynolds
6 Jan 2014, 11:09 AM
Sorry, I'm being dumb...I meant to be saying 'comment' not 'uncomment'. So in the fiddle, comment out line 10 having 'likesToEat'.

Gary Schlosberg
18 Jan 2014, 5:29 PM
You might take a look at this:
https://github.com/mitchellsimoens/Ux.grid.plugin.AssociationRowExpander