-
16 Apr 2009 8:47 AM #1
[3.0] Ext.data.store DataWriter ¿can I send one request when I add some records?
[3.0] Ext.data.store DataWriter ¿can I send one request when I add some records?
When I add some records to a store and use commitChanges or save, it sends one request to the server for each record, ¿Is there any way to do it in one request?
thanks
-
17 Apr 2009 4:16 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,170
- Vote Rating
- 32
I have not really worked with writer yet, so I don't know if there is a config option.
I know that Direct does this.
Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
17 Apr 2009 5:45 AM #3
yes you can do this
store has batchSave config option
code snipped from the writer example
Code:var store = new Ext.data.Store({ id: 'user', root: 'records', proxy: proxy, reader: reader, writer: writer, // <-- plug a DataWriter into the store just as you would a Reader paramsAsHash: true, batchSave: true// }); and the use store.save(); to saveShibu Bhattarai
Use JavaScript beautifier to beautify you code http://jsbeautifier.org/
Code Conventions http://javascript.crockford.com/code.html
ExtJS Core Manual http://extjs.com/products/extcore/manual/
-
17 Apr 2009 6:18 AM #4
the API says:
batchSave : Boolean
Defaults to false, which requires manually calling save to send all modifiedRecords to the server. Specify true for the store to automatically save records to the server when a record changes.
The problem is when I add for example 2 records and save, I expect it sends an array with the changes but it sends 2 requests. I attached and image with what shows firebug.
thanks
-
17 Apr 2009 8:10 AM #5
This functionality was demoed at the conf, so it may be that it was fixed post-RC1. Can you post a testcase?
Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
17 Apr 2009 9:06 AM #6
A simple test:
And what shows firebug.Code:Ext.onReady(function() { /*record*/ var rProf = Ext.data.Record.create(['id', 'Nombre', 'Apellidos', 'Correo']); /*store*/ var lProf = new Ext.data.Store({ root: 'records', proxy: new Ext.data.HttpProxy({ prettyUrls: false, url: 'datos.php?op=mprof' }), reader: new Ext.data.JsonReader({ totalProperty: 'total', successProperty: 'success', idProperty: 'id', root: 'data' }, rProf), writer: new Ext.data.JsonWriter({ returnJson: true, writeAllFields: false }), paramsAsHash: true, batchSave: false }); /*new records*/ var nr = new rProf({ Nombre: 'test1', Apellidos: 'Atest1' }); var nr2 = new rProf({ Nombre: 'test2', Apellidos: 'Atest2' }); /*add records*/ lProf.add(nr); lProf.add(nr2); /*save changes*/ lProf.save(); });
thanks
-
17 Apr 2009 9:13 AM #7
I'm just poking my nose in here. But it says batchSave. The api actions are different aren't they? So you're looking for something like batchCreate it seems.
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
-
17 Apr 2009 9:14 AM #8
Edit: I wasn't at the conference so I don't really know what I'm talking about...
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
-
17 Apr 2009 9:49 AM #9
Looking at the source it appears the create action is set up to fire the requests individually, not as an array.
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
-
17 Apr 2009 6:23 PM #10Shibu Bhattarai
Use JavaScript beautifier to beautify you code http://jsbeautifier.org/
Code Conventions http://javascript.crockford.com/code.html
ExtJS Core Manual http://extjs.com/products/extcore/manual/


Reply With Quote

