PDA

View Full Version : loading into grid problem ...



ssgam
28 Mar 2010, 12:48 PM
Hi All,

i'm trying to load a second grid from a store i created earlier from server
generated JSON data.

the relevant code looks like this:

var store1 = new Ext.data.JsonStore({
url: 'Summary',
id: 'store1',
root: 'summary',
fields: [
'field1',
'field2',
'field3',
'arrayfield'
]
});

var store2 = new Ext.data.JsonStore({
id: 'store2',
fields: [
'nfield1',
'nfield2',
'nfield3'
],
data: []
});

var summary = new Ext.grid.GridPanel({
id: 'summary',
title: 'summary',
stripeRows: true,
store: store1,
columns: [
{header: "field1", dataIndex: 'field1', sortable: true},
{header: "field2", dataIndex: 'field2', sortable: true},
{header: "field3", dataIndex: 'field3', sortable: true}
],
view: new Ext.grid.GridView()
});

var details = new Ext.grid.GridPanel({
id: 'details',
stripeRows: true,
store: store2,
columns: [
{header: "nfield1", dataIndex: 'nfield1', sortable: true},
{header: "nfield2", dataIndex: 'nfield2', sortable: true},
{header: "nfield3", dataIndex: 'nfield3', sortable: true}
],
view: new Ext.grid.GridView()
});

var last_id = -1;

summary.getSelectionModel().on('rowselect', function(sm,index,record){

if ( last_id != record.id ) {

store2.loadData(record.get('arrayfield'));
...
...

The funny thing is that the second grid loads only one line/record from
the array that is defined in "arrayfield".

i checked the JSON reply in firebug, and it shows that the data returned has more than
one record...

what am i doing wrong?

Thanks!
sam

fay
28 Mar 2010, 2:37 PM
1. Try to post your code in [CODE] tags. See: http://www.extjs.com/learn/Ext_Forum_Help#How_to_post_code_properly

2. There's no need to explicitly create your view - it's created automatically if you don't specify one. Note, however that you can use viewConfig to change how the "default" view *looks*.

3. Have you checked that your (container) layout is correct for the second grid? Have you specified a height/autoHeight for it?

ssgam
28 Mar 2010, 11:21 PM
Thanks Fay,

i added autoHeight to the grid component, now, the individual records
for the grid is now display.

another question...

i have added the grid to the west panel (border layout), but i can't
get the horizontal scroll bar to appear, when i chose to display some
hidden fields (which now stretch beyond the default width ...

i've added autoScroll, do autoHeight, autoWidth cancel out one another ?

Thanks,
sam

Animal
29 Mar 2010, 12:56 AM
I worry when I hear "added the grid to".

Implies you have a no layout Panel to which you add the grid.

autoHeight and autoWidth cancel any size management by a layout. But if you have no layout, you have double-screwed it.

Use the grid as the west panel.