Automatic search after selected field in searchselectfield DataGrid

1
Is it possible to start the search action automatically when I select one item in a selectfield in the DataGrid? For now I must hit the search button to start the action.
asked
1 answers
2

AFAIK this is not possible out of the box but should be fairly easy to accomplish with a small javascript snippet.

//find the datagrid
var dataGrid = document.querySelector('.mx-datagrid.mx-name-products');

//find the select element and search button
var itemsSelect = dataGrid.querySelector('.mx-grid-search-input.mx-name-itemsField > select')
    searchButton = dataGrid.querySelector('.mx-grid-search-controls > button.mx-grid-search-button') 

//whenver the select option is changed trigger a click on the search
itemsSelect.onchange=function() {
   searchButton.click();
};

Make sure to put the javascript snippet after the datagrid in the modeler so that it loads after the grid is loaded.

answered