user1509885
user1509885

Reputation:

CRUD application with API (how to conf API properly) - Ext-JS 4

I have a working CRUD application but with U (update) I have a question.

In my store I have:

...........

proxy: {
        type: 'ajax',
        api: {
            create  : '../mega_sabrina_cake/workers/create',
            read    : '../mega_sabrina_cake/workers/index',
            update  : '../mega_sabrina_cake/workers/update',
            destroy : '../mega_sabrina_cake/workers/delete'
        },
        actionMethods: {
            create  : 'POST',
            read    : 'POST',
            update  : 'POST',
            destroy : 'POST'
        },
        reader: {
            type: 'json',
            root: 'Worker',
            rootProperty: 'Worker',
            successProperty: 'success',
            messageProperty: 'message'
        },
        writer: {
            type: 'json',
            writeAllFields: true,
            root: 'data',
            encode: true
        },

...........

When submitting form for editing, I have a url specified:

....
panel.getForm().submit({
            url: '../mega_sabrina_cake/workers/edit',
            success: function(form, action) {
            Ext.Msg.alert('Success', "The Worker has been edited!");

...

So, how can I use the url from the store to avoid putting url in form?

Upvotes: 0

Views: 667

Answers (1)

dbrin
dbrin

Reputation: 15673

Form does not use the store it uses its own submit method to communicate to the server. If you want to use the Store or Model proxy (you can define the same proxy config on the Model as you did on the store) you can do the following:

form.updateRecord(record) and use store.sync() or model.save()

here is an example you could follow: http://docs.sencha.com/ext-js/4-1/#!/example/writer/writer.html

Upvotes: 1

Related Questions