7

How do I handle the save() method of the data store on the back end.(my C# code)?
Do I need any extra config settings for the store to enable the save() method? If anyone could just point me in the right direction that would be great?

    var writer = new Ext.data.JsonWriter({
    encode: true
});

// create the Data Store
var store = new Ext.data.JsonStore({
    root: 'Data.items',
    idProperty: 'Empid',
    writer: writer,
    fields: ['Empid', 'Firstname', 'Surname', 'Username'],
    proxy: new Ext.data.HttpProxy({
        url: AppRootPath + 'EmployeeDetails/GetSAASUsers',
        method: 'POST'
    })//proxy
});//new Ext.data.JsonStore

Hod do i configure my stiore to support a save method which will update the records in the database?

tshepang
  • 12,111
  • 21
  • 91
  • 136
shane87
  • 3,090
  • 12
  • 51
  • 65

3 Answers3

11

Ext.data.Store.commitChanges() is a client-side-only method. It does not communicate with the server in any form. The method is used to reset the modification status of the store's records and persist their changes (on the client-side only).

Ext.data.Store.save() is the method that actually uses the configured connection to talk to your server-side application. To be able to provide more information you'd need to post some code snippets.

Stefan Gehrig
  • 82,642
  • 24
  • 155
  • 189
  • Thanks, I have changed the question and added some code. How do I handle the save method on the server side? Do I need to specify something else in the store config for this? – shane87 Mar 14 '11 at 14:16
  • @Shane87. For the C# side. Are you using WCF services? MVC? – subv3rsion Mar 14 '11 at 16:48
  • @Shane87: Unfortunately I am more familiar with WCF and EXT JS. Could you post some code snippets you have from the server side? Like the EmployeeDetails Controller? – subv3rsion Mar 14 '11 at 17:56
  • 1
    @Shane87: Guessing MVC3? [link] (http://myxaab.wordpress.com/2011/02/20/extjs-and-asp-net-mvc-3-crud-datagrid/) – subv3rsion Mar 14 '11 at 17:58
  • 4
    Note that Ext.data.Store.save() has been deprecated in ExtJS 4.x; one must use [Ext.data.Store.sync()](http://docs.sencha.com/extjs/#!/api/Ext.data.Store-method-sync) instead. – Gaëtan Frenoy Jul 27 '13 at 08:48
0

Config option autoSync is available for stores since ExtJS 4.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
-2

I am not familiar with C#, but I would imagine you would need to send your stores data as a JSON Object to your C# cost with some kind of Ajax request