Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write to a memoryproxy in Ext.js

Tags:

extjs

I'm trying to use Extjs with a javascript view model. I've had success with loading stores using a JsonReader and the ext.data.memoryproxy class.

However I want to write changes to my Javascript viewmodel.I tried adding a jsonwriter to the writer property of the store but this doesn't work. I get this error:

uncaught exception: Ext.data.DataProxy: DataProxy attempted to execute an API-action but found an undefined url / function. Please review your Proxy url/api-configuration.

My Code is:

var service = viewmodel.selectedService.analytes;

     var serviceResultsStore = new Ext.data.Store({
        reader: new Ext.data.JsonReader({
            fields: ['Analyte', 'Units', 'Value', 'Rounded', 'PossibleValues']

        }),
        proxy: new Ext.data.MemoryProxy(service),
           writer: new Ext.data.JsonWriter({
                    encode: false,
                    writeAllFields:true
                })

Any Help on this would be greatly appreciated!

like image 242
Almond Avatar asked Nov 14 '22 03:11

Almond


1 Answers

JsonWriter and a MemoryProxy won't work well together. They are not intended to.
From the JsonWriter docs,

DataWriter extension for writing an array or single Ext.data.Record object(s) in preparation for executing a remote CRUD action.

JsonWriter extends DataWriter. From DataWriter docs -

Ext.data.DataWriter facilitates create, update, and destroy actions between an Ext.data.Store and a server-side framework. A Writer enabled Store will automatically manage the Ajax requests to perform CRUD actions on a Store.

I am not sure what your high level design/intention around this is but in this case, maybe you can get the records from the store, modify them and commit them back to the store? (You can do all the CRUD operations directly on the store)

like image 122
Amol Katdare Avatar answered Dec 14 '22 23:12

Amol Katdare