-
9 Feb 2009 12:48 PM #1
about how to add data to Form + grid
about how to add data to Form + grid
ok, i'll tell a short history about what am i doing ...
i need to load data from XML
and because i have a window with tab pannel i used a formpanel in tab 1 and a grid panel in the second tabHTML Code:<rows> <data name='' value='' /> ..... <rows>
i'm loading part of the data into the form panel and the rest on the grid panel....
ok... i begin loading the data with a Datastore (XMLReader/HttpProxy) and later using the load listener to fill the data into the formpanel and later calling LoadData(oData, bAppend) to fill the DataStore (ArrayReader/MemoryProxy) using the data from the first datastore to load the seccond APPEDING the adquired data.
everything appears to flowing perfectly but i can't make that the fields update the values when the new data is adquired ... debugging with firefox apparently i'm doing fine ... but really i don't know whats is really happening ...
The question is ...Code:store : new Ext.data.Store({ proxy : new Ext.data.HttpProxy({url : 'datos/detObjeto.asp'}), id : 'nombre', reader : new Ext.data.XmlReader({ record : 'data', id : '@name' }, [{name: 'tname', mapping: '@name'}, {name: 'tvalue', mapping: '@value'}] ), listeners :{ 'load' : function( oDts, oRecs, oOpts){ var cont; for(cont=0;cont < oRecs.length;cont++ ){ if(oRecs[cont].get('tname') == 'XXXX'){ Ext.getCmp('txtXXXX').value=oRecs[cont].get('tvalue'); continue; }// Code to update the field value Ext.getCmp('grdXXXX').store.loadData(oRecs[cont].data,true);// Code to fill the grid }
thius is the best way to update the data into the form components ? ....
if need more details say it[extjs 2.2]
[Browsers: IE(6/7/8), FF (3.0.8), chrome 2.0]

-
9 Feb 2009 12:54 PM #2
I am not going to write it out for you exactly but this is what I did.
profileName.setValue(obj.getAt(r).get('profileName'));
profileName is the name of the profileName text field. r= the record, and profileName is the datastore reader value for the data element ({name: 'profileName', mapping: 'profileName', type: 'string'} as you can see.)
I am sure that there might be a better way to take data from a datastore and place it into fields, but this seems to work rock solid for me. Have fun!
Mike
-
10 Feb 2009 11:52 AM #3
i will try that but what about the method used to fill teh grid
[extjs 2.2]
[Browsers: IE(6/7/8), FF (3.0.8), chrome 2.0]

-
10 Feb 2009 1:03 PM #4
-
12 Feb 2009 11:07 AM #5
HI ty for the reply,
my field finally update
i did this
instead of :Code:Ext.getCmp('tpZZZ').form.findField("txtXXX").setValue(oRecs[cont].get('tvalue'));
but i'm not having any succes loading the grid with my new dataCode:Ext.getCmp('txtXXXX').value=oRecs[cont].get('tvalue');
any ideas about how can i load the data ?Code:Ext.getCmp('grdXXXX').store.removeAll(); Ext.getCmp('grdXXXX').store.loadData(oRecs[cont].data,true); Ext.getCmp('grdXXXX').store.commitChanges();
This is how i declared my grid (panel)
Code:{ title : '...', xtype : 'grid', id : 'grdXXXX', store : new Ext.data.Store({ proxy : new Ext.data.MemoryProxy([]), id : 'dtsExtra', reader : new Ext.data.ArrayReader({},[{name: 'tname'},{name: 'tvalue'}]) }), columns: [ {header: "Property", width: 200, sortable: true, dataIndex: 'tname'}, {header: "Value", width: 120, sortable: true, dataIndex: 'tvalue'} ], viewConfig: { forceFit: true } }[extjs 2.2]
[Browsers: IE(6/7/8), FF (3.0.8), chrome 2.0]

-
12 Feb 2009 12:14 PM #6
If oRecs[cont].data is valid, I think that all you should have to do is:
PHP Code:Ext.getCmp('grdXXXX').store.loadData(oRecs[cont].data, false);
Ext.getCmp('grdXXXX').getView().refresh();
-
16 Feb 2009 7:44 AM #7
ok. I updated the gridview but now i have an scope problem.... :S
firebug says:
any ideas .... ¿?Code:Ext.getCmp('grdXXXX').getView().refresh(); <------ Error on this line ---------------------------- this.grid is undefined http://.../extjs/ext-all.js Line 144[extjs 2.2]
[Browsers: IE(6/7/8), FF (3.0.8), chrome 2.0]

-
16 Feb 2009 8:10 AM #8
MJ
API Search || Ext 3: docs-demo-upgrade guide || User Extension Repository
Frequently Asked Questions: FAQs
Tutorial: Grid (php/mysql/json) , Application Design and Structure || Extensions: MetaGrid, MessageWindow
-
16 Feb 2009 9:34 AM #9
oops shame!!! ...
ok in this line
extjs-all-debug.js
FYI - not develop too much in extjs currently making test on itCode:31590 refresh : function(headersToo){ 31591 this.fireEvent("beforerefresh", this); 31592 this.grid.stopEditing(true); //<---- ERROR!!!!!!! 31593 31594 var result = this.renderBody(); 31595 this.mainBody.update(result); 31596 31597 if(headersToo === true){ 31598 this.updateHeaders(); 31599 this.updateHeaderSortState(); 31600 } 31601 this.processRows(0, true); 31602 this.layout(); 31603 this.applyEmptyText(); 31604 this.fireEvent("refresh", this); 31605 }[extjs 2.2]
[Browsers: IE(6/7/8), FF (3.0.8), chrome 2.0]

-
16 Feb 2009 9:44 AM #10
I'd suggest reposting your latest code. Can't quite get where you're at now.
MJ
API Search || Ext 3: docs-demo-upgrade guide || User Extension Repository
Frequently Asked Questions: FAQs
Tutorial: Grid (php/mysql/json) , Application Design and Structure || Extensions: MetaGrid, MessageWindow


Reply With Quote