0

I'm now trying to connect Extjs with a web rest api apart from my project. This is my view:

    Ext.define('mycomponents.view.comboselview', {
        extend: 'Ext.container.Container',
        id: 'comboview',
        alias: 'widget.comboview',
        xtype: 'comboview',
        requires: [
            'mycomponents.model.comboselmodel'
        ],
        items: [
            {
                xtype: 'combobox',
                reference: 'levels',
                publishes: 'value',
                fieldLabel: 'Choices',
                displayField: 'description',
                anchor: '-15',
                store: {
                    type: 'levels'
                },
                minChars: 0,
                queryMode: 'local',
                typeAhead: true,
                labelWidth: 100,
                labelAlign : 'right',
                width: 265,
                allowBlank: false
            }
        ],
        initComponent: function () {
            this.callParent(arguments);
            var that = this;
            console.log('!!!!!!!!!!!!!!!!!!!!!!>>>', that.up());
        }
});

Here is my model:

        Ext.define('mycomponents.model.comboselmodel', {
            extend: 'Ext.data.Model',
            fields: [
                {
                     name: 'id',
                     mapping: 'pk'
                },
                {
                     name: 'description',
                     type: 'string',
                     mapping: 'description'
                },
                {
                     name: 'levelid',
                     type: 'integer',
                     mapping: 'levelid'
                },
                ...
            ]
        });

and my store:

Ext.define('mycomponents.store.comboselstore', {
    extend: 'Ext.data.Store',
    alias: 'store.levels',
    model: 'mycomponents.model.comboselmodel',
    storeId: 'levels',
    restful: true,
    autoLoad: true,
    proxy: {
        type: 'ajax',
        headers: {
           'Accept': '*/*',
           'Cache-Control': 'no-cache',
           'Content-Type': 'application/json',
           'Authorization': localStorage.token
        },
        extraParamas: {
           sort: 'description',
           filter: {
               idlevel: {
                   'null': -1
               }
           }
        },
        reader: new Ext.data.JsonReader({
        }),
        writer: new Ext.data.JsonWriter({
        }),
        actionMethods: {
           read: 'GET'
        },
        api: {
           read: 'apiurl',
           create: 'apiurl',
           update: 'apiurl',
           destroy: 'apiurl'
        },
        autoSave: true
    },
    constructor: function (config) {
        this.callParent([config]);
        console.log('I am entering here!!!')
    }
});

I'm trying to fetch resources from my apiurl which is a web rest api. I need to send some parameters, this code returns me the desired data, but this approach ignores the extraParamas at all. I can't tell that I went into the documentation and found how to use Extjs with a rest api becasue I was unable to find how to do that in the official documentation, so, I've been googleing for a solution and what I've made so far is getting code snippets from here and there. My question: how to send paramenters to a rest api? what am I doing wrong?

2
  • 1
    There's a typo in your code, extraParamas, when it should be extraParams, extraParams will send these parameters in the URL, is that what you want? Commented Apr 25, 2019 at 19:24
  • @MatheusHatje, thank you... it was very naive from my side... post it as a response to upvote your and mark it as solution Commented Apr 25, 2019 at 19:32

1 Answer 1

1

There's a typo in your code, extraParamas, when it should be extraParams

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.