PDA

View Full Version : how work CRUD or how can i use CRUD ?



masoud_tamizy
22 Jan 2012, 12:21 AM
do you know how can i do CRUD as simple way with ajax ?
my code is in following post :
http://www.sencha.com/forum/showthread.php?175208-I-encounterde-this-error-on-loading-data-from-server-to-a-grid
(http://www.sencha.com/forum/showthread.php?175208-I-encounterde-this-error-on-loading-data-from-server-to-a-grid)but with some changes (will mention below):
api:{
read : 'prepare.php',
delete : 'delete.php'
}
but i don't know how can i do for delete or update operations !!!

what method or property have to be setted to it work ???

chramer
23 Jan 2012, 12:39 AM
I hope this helps!
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.proxy.Ajax-cfg-api (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.proxy.Ajax-cfg-api)

masoud_tamizy
23 Jan 2012, 1:17 AM
I hope this helps!
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.proxy.Ajax-cfg-api (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.proxy.Ajax-cfg-api)
thanks , but i didn't understand how it work , i.e what happened for e.g update operation and what method lead to do it ?

chramer
23 Jan 2012, 5:07 AM
Let's say you have a grid! And you perform some changes (inserts/update/delete).
The grid has a store, the store has a proxy. :)
So.. the changes that you've made in the grid, you want to send them to the server.

For that you use the "sync (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.data.Store-method-sync)" method :


grid.getStore().sync();

The sync method will determine what data will be sent and where (depending of your "api" config) it will be sent!
Was I clear ?

lorezyra
23 Jan 2012, 3:55 PM
Perhaps you should spend a little time in the LEARN section of this site...

http://www.sencha.com/learn/the-data-package/

(http://www.sencha.com/learn/the-data-package/)http://www.sencha.com/learn/the-grid-component/

It would also help greatly if you were to pick up the book "ExtJS in Action (http://www.manning.com/garcia/)" by Jessie Garcia. Even though it's for ExtJS 3.x, the techniques for applying CRUD/REST-based stores and grids still work well for ExtJS 4. I heard that Jessie is working on updating his book to cover version 4. I find myself referencing it from time to time.