Good day to all. Please tell me how to solve the following problem. Faced extjs 5.1, previously did not work with it.

The question is the following interface:

enter image description here

I implement the search for students through AJAX. There is such code:

Ext.Ajax.request({ url: '/admin/learner/getLearnerBySearch', params: { search: inputSearch.rawValue }, waitMsg: 'Загрузка...', success: function(data) { //????.html(data.responseText); Как тут быть? } }); 

With this code, I give the search value to the controller, pull the request to the right people in JSON format and get the following string:

 [{ "id": 16, "fio": "\u041a\u043b\u0438\u043c\u043e\u0432\u0430 \u0412\u0430\u043b\u0435\u0440\u0438\u044f", "email": "ms.klg4545453@mail.ru", "phone": "+7(920)31445459", "group": "244", "block": 0 }] 

Now the question is, in which element in extjs to insert this line into success, so that those entries that came from the controller and everything worked correctly appeared in the window above.

    1 answer 1

    You do not need to make an Ext.Ajax.request query for the Grid. He has a Store for that.
    In the search handler, do something like this:

     grig.getStore().addFilter({property: 'any', value: inputSearch.rawValue, operator: 'like'}); grid.getStore().loadPage(1); // если autoLoad: false 

    The store must have the config remoteFilter: true .
    AddFilter method: https://docs.sencha.com/extjs/5.1.3/api/Ext.data.Store.html#method-addFilter

    As a result, the Store will be loaded from the server with the parameter:

     filter:[{"property":"any","value":"keyword","operator":"like"}] 

    Which already on the server disassemble and filter.

    But you can simply add a parameter to the download:

     grid.getStore().getProxy().setExtraParam('search', inputSearch.rawValue); grid.getStore().loadPage(1); 

    Then a request with the parameter will go to the server ?search=...

    • Thanks It works. - Nick