|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
[Q] input arguments to JsonRestStore vs PersevereStoreTrying to stitch-in a complete working restful store with PHP backend
from various web posts. So I apologize for sending different questions around the same topic. But my results do not work the same way that I think, the examples were intending for example. This is how I define the service and store. -------------------------------------------------- var crmService = function(query, queryOptions) { console.log('calling query: ',query, " with options: ",queryOptions); return dojo.xhrGet({url:"services", handleAs:'json',content:{action:'query',"query":query, "queryOptions":queryOptions}}); }; crmService.post = function(id, value) { console.log('calling add with id:',id, ' and value: ',value); return dojo.xhrPost({url:"addService", handleAs:'json', content:{action:'add',"id":id, "value":value}}); }; var crmServicesStore = new dojox.data.JsonRestStore ({target:"<?php echo $controller; ?>", service:crmService, syncMode:false }); ---------------------------------------- for some reason the arguments passed in to the functions above are a) different between Restore and PersevereStore b) ID argument to the add is never populated (empty string) (I am checking it by printing out $_REQUEST array in php To point a) the initial query shows as Object name:'*' console.log('calling query: ',query, " with options: ",queryOptions); and does NOT get serialized to a string xhrGet (however the example here http://blog.medryx.org/tag/jsonreststroe/ ) does not have any special login to serialize the 'query' object On the other hand, when using PerserveStore, the query is already a serialized string (of course with different syntax than the RestStore query) so that one shows up up $_REQUEST array in PHP and where does RestStore get the property name 'name' for the query, is this a default? The 'id' value never gets populated on the store.newItem (that invokes crmService.post ) Unlike typical stores, I guess, I do not need to define the 'identity' element or the store schema at all, I see that __id element in the item gets always populated with some random but unique number. Which is good for me. So wanted to ask for recommendation my basic need is a Store that a) sends update/delete/updates to my PHP server b) does not go to the server if the query finds at least one item in internal memory (or if I specify some argument like cache:true or something similar) c) tells me the identity of the item being sent d) does not require me to manage the identity items I think the stores above do all (or most) of the things above, but may be I just cannot find the right combination of switches in the plethora of options and documents available.... Vlad -- Vlad P author of C++ ORM http://github.com/vladp/CppOrm/tree/master -- http://www.fastmail.fm - Access your email from home and the web _______________________________________________ FAQ: http://dojotoolkit.org/support/faq Book: http://dojotoolkit.org/docs/book Forums: http://dojotoolkit.org/forum Dojo-interest@... http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest |
|
|
Re: [Q] RESOLVED input arguments to JsonRestStore vs PersevereStoreGot the
client side querying of the Perserve data store to work Maulins reply had me going in right direction about using clientFetch but this web page http://docs.dojocampus.org/dojox/data/ClientFilter listed one more thing to get this to work (that I was missing) ----- To use the ClientFilter with a data store which offers optional support of ClientFilter (like dojox.data.ServiceStore and dojox.data.JsonRestStore), it's important to observe the correct sequence: include dojox.data.ClientFilter include the data store set queryOptions:{cache:true} in the request or use a Widget with a option to cache each request (for example the Grid with the queryOptions attribute: <table queryOptions="{cache:true}" dojoType="dojox.grid.DataGrid" ...) ----------------- I was missing the 'or' part -- that is enabling in the Grid queryOptions="{cache:true}" I had option set on the store, then on the query, but not on the grid. And I guess that was causing not being able to find any items except the last added one, and it was causing queries to go to the server. The only remaining part for me to resolve now is why > crmService.post = function(id, value) { > console.log('calling add with id:',id, ' and value: ',value); > return dojo.xhrPost({url:"addService", handleAs:'json', > content:{action:'add',"id":id, "value":value}}); > }; does not get the id argument populated when invoked (I assume it is the identity for the row being inserted) VSP -- Vlad P author of C++ ORM http://github.com/vladp/CppOrm/tree/master -- http://www.fastmail.fm - Access your email from home and the web _______________________________________________ FAQ: http://dojotoolkit.org/support/faq Book: http://dojotoolkit.org/docs/book Forums: http://dojotoolkit.org/forum Dojo-interest@... http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest |
|
|
Re: [Q] RESOLVED input arguments to JsonRestStore vs PersevereStore-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 V S P wrote: > Got the > client side querying of the Perserve data store to work > > Maulins reply had me going in right direction about using clientFetch > > but this web page > http://docs.dojocampus.org/dojox/data/ClientFilter > > listed one more thing to get this to work (that I was missing) > > ----- > To use the ClientFilter with a data store which offers optional support > of ClientFilter (like dojox.data.ServiceStore and > dojox.data.JsonRestStore), it's important to observe the correct > sequence: > include dojox.data.ClientFilter > include the data store > > set queryOptions:{cache:true} in the request > > or use a Widget with a option to cache each request (for example the > Grid with the queryOptions attribute: > > <table queryOptions="{cache:true}" dojoType="dojox.grid.DataGrid" ...) > ----------------- > > > I was missing the 'or' part -- that is enabling in the Grid > queryOptions="{cache:true}" > > > I had option set on the store, then on the query, but not on the grid. > > And I guess that was causing not being able to find any items except the > last added one, > and it was causing queries to go to the server. > > > The only remaining part for me to resolve now is why > >> crmService.post = function(id, value) { >> console.log('calling add with id:',id, ' and value: ',value); >> return dojo.xhrPost({url:"addService", handleAs:'json', >> content:{action:'add',"id":id, "value":value}}); >> }; > > > does not get the id argument populated when invoked (I assume it is the > identity for the row being inserted) > return the new id in the "Location" header in the response. If you actually do really like the ids assigned by the client, the server doesn't need to return a Location header, and the server can determine the client assigned id from the Content-ID header on the request. - -- Kris Zyp SitePen (503) 806-1841 http://sitepen.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkpNtIsACgkQ9VpNnHc4zAx8OwCff+YyGxslIPn/p5nPz1XQUfwe p1gAn1fmmfd0mIzaGZjc5w4c6RTeDzaL =EsVx -----END PGP SIGNATURE----- _______________________________________________ FAQ: http://dojotoolkit.org/support/faq Book: http://dojotoolkit.org/docs/book Forums: http://dojotoolkit.org/forum Dojo-interest@... http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest |
| Free embeddable forum powered by Nabble | Forum Help |