1. #1
    Sencha User
    Join Date
    Sep 2010
    Posts
    6
    Vote Rating
    0
    saurabh_agarwal15 is on a distinguished road

      0  

    Default Posta store to server

    Posta store to server


    Hi,

    We can use json objects to send the data to the client side using post or get method. That works perfectly cool. My concern is pther way round.
    Let say I have a data store and i want to send this data store to the server then what is the best approach to do that. Further do extjs provide any method for this.

    Code:
     
    demoStore = new Ext.data.Store({
      id :'demoStore',
      data: [
        ["A","216","java",],
        ["B","209","php",],
        ["C","10","dotnet"]
      ],
      reader: new Ext.data.ArrayReader({id:'id'}, [
        'name',
        'id',
        language'
       ]) 
     });
    Regards,
    Saurabh

  2. #2
    Sencha - Services Team arthurakay's Avatar
    Join Date
    Sep 2008
    Location
    Antioch, IL
    Posts
    1,363
    Vote Rating
    33
    arthurakay is a jewel in the rough arthurakay is a jewel in the rough arthurakay is a jewel in the rough

      0  

    Default


    I probably wouldn't attempt to batch update all records in a database - I'd probably just use the "add" or "update" events on the Store() object, sending the data for each record that gets added/edited as separate AJAX requests.
    Arthur Kay
    Developer Relations Manager, Sencha Inc.

    Twitter | Sencha Chicago User Group

  3. #3
    Sencha User
    Join Date
    Sep 2010
    Posts
    6
    Vote Rating
    0
    saurabh_agarwal15 is on a distinguished road

      0  

    Default


    Hi arthur,

    In scenarios, yes you are right, but my requirement says that all of the data is to be updated as a whole or nothing is to be updated, and hence i am maintaning the data store on the client side. Now since i am successfull in maintaining the data store throughout the process i do not want to convert it to some other format set it to some hidden field(or any other variable) and then send it across to server. Rather i am looking for a mechanism in which i can send the complete data store as it is, and will parse it as we do with the json stores.

    I hope you got my point.

    Regards,
    Saurabh Agarwal

  4. #4
    Sencha - Services Team arthurakay's Avatar
    Join Date
    Sep 2008
    Location
    Antioch, IL
    Posts
    1,363
    Vote Rating
    33
    arthurakay is a jewel in the rough arthurakay is a jewel in the rough arthurakay is a jewel in the rough

      0  

    Default


    I suppose you could have a "save" button in your toolbar with the following handler:
    PHP Code:
    var dataArray = [];

    function 
    getData(record) { dataArray.push(record.data); }

    myStore.each(getData);

    Ext.Ajax.request({
      
    url'doSomething.php'
      
    params: {
        
    dataExt.encode(dataArray)
      },
      
    success: function(responseoptions) {}
    }); 
    Basically, you just need to serialize each of the records in your store and send to the server. You could implement that in a number of ways, but I'd probably use the method above unless someone has a better implementation.

    Alternatively, you could use the save() method on the data store - which saves all *pending* changes to the store. Latching onto the "save" event, you could launch an AJAX call to the server containing only the records that have changed. The handler would be similar to what I described above, but only looping over the records with pending changes (not necessarily ALL records in the store).
    Arthur Kay
    Developer Relations Manager, Sencha Inc.

    Twitter | Sencha Chicago User Group

Similar Threads

  1. Ext.data.Store server communication
    By triple in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 30 Mar 2010, 2:10 PM
  2. Grid Extension columns and store from server from server
    By qulys in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 23 Nov 2009, 2:09 AM
  3. Stop the server request from store ?
    By ritesh.kapse in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 9 Sep 2008, 7:08 AM
  4. Persist Store to server?
    By deitch in forum Ext 1.x: Help & Discussion
    Replies: 7
    Last Post: 18 Oct 2007, 6:16 AM
  5. Saving data from a store to server
    By marco.braga in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 3 Sep 2007, 7:02 AM

Thread Participants: 1

Tags for this Thread