View Full Version : [SOLVED] loadRecord() not populating all fields

23 Feb 2010, 7:03 AM
I've got a grid that, on rowclick, pops up a window with a form. The problem is, that the grid contains only a subset of the fields that make up an entire record, and so the record object that gets passed to the form doesn't have all the fields I need. Here's the handler:

ug = new App.userGrid();
ug.getSelectionModel().on('rowselect',function(sm, rowIndex, record){
uw = new App.userWindow();
// url : 'includes/json/user-detail.php',
// method : 'GET',
// params : { userid : record.data.userid }

Ext.getCmp('centerRegion').add( ug );

I need an object that contains all the fields for the form. I've done forum searches and haven't found a solution to this problem. The commented line is the only one I found that I thought might work, using load() instead of loadRecord(), but it doesnt. I'm basically calling a separate php file to get back a full record JSON object by passing userid from the original object. The JSON response from this new php file is good, but the load() method doesn't do anything to the form. Do I need to map the JSON fields to the form in some way? Or do I need to create a new Ext.data.Record and pass that in to loadRecord() ?

Any tips are appreciated!



23 Feb 2010, 7:14 AM
Keep your grid's column model the same, but expand your store to hold all fields, and return all fields when populating the store.

Then just pass the new record or the record index into your window's constructor function in some way and use that to load.

23 Feb 2010, 7:21 AM
Awesome, that did it. Thanks! It's always so simple once the solution is pointed out :)

For some reason I thought there had to be a 1:1 mapping of fields in the store, to fields defined in the grid's column model.

Thanks again,


23 Feb 2010, 9:08 AM
Nope - I'm keeping it pretty simple. The grid is static, simply as a cleaner presentation of tabular data. The only interaction with the grid is the rowselect event, which spawns the window.

Thanks again!