开发者

Writing store updates back to server

开发者 https://www.devze.com 2023-03-28 17:08 出处:网络
I have read the Sencha tutorials, API, and forums for awhile but am hitting a brick wa开发者_如何学JAVAll. I have a mySQL/PHP backend that is storing a web application\'s data. I have the following Se

I have read the Sencha tutorials, API, and forums for awhile but am hitting a brick wa开发者_如何学JAVAll. I have a mySQL/PHP backend that is storing a web application's data. I have the following Sench/ExtJS construct:

App.stores.user = new Ext.data.Store({
  model: 'User',
  proxy: new Ext.data.AjaxProxy({
      url: 'app/stores/scripts/connect.php',
      extraParams: {
          method:'user',
          user_id: 3
      },
      reader: {
          type:'json',
          root:'root'
      }
  }),
  autoLoad:true
});

Data is loaded into the store fine, but I have a form that directly updates a User instance.

App.controllers.account =  new Ext.Controller({
    save: function (options) {
        options.user.set(options.data);
        options.user.save(); // Generates error: Uncaught Error: You are using a ServerProxy but have not supplied it with a url.
    }
});

How can I successfully implement/hook the functions to write the dirty records back to the server? How is the request prepared and passed?

Thank you.


Uptil Ext Js 3.3.1 the store needs to be configured with a writer when performing CRUD operations. It isn't needed for read only. That's why your store is loaded but you're getting an error during write operations. In your case you'll have to specify a JsonWriter. Also, if you're not using the store in a restful manner, then you'll also need to specify a HttpProxy object to tell the store at which url to publish the create/update/delete on the store.

Check the docs for Ext 4. I should be something similar here too.

0

精彩评论

暂无评论...
验证码 换一张
取 消