How to fetch the filter types of column filter in DATAGRID2

0
Hello All, I have used column filter in datagrid2. I am able to store  the filter values , but not able to get Column filter types(ex: Contains, Start with,  End With, etc…..)  Is there any possible way to get a column type, For reference, I have attached an image below :    Thanks in advance 
asked
1 answers
2

Hi Neela,

1.Add Custom JavaScript Snippet: First, you'll need to add a custom JavaScript snippet to your Mendix app. To do this:

a. Open your Mendix project in Mendix Studio Pro. b. Navigate to your Data Grid 2 widget's page and open it for editing. c. Add a new HTML snippet widget to the page. d. In the HTML snippet's configuration, add your custom JavaScript code.

2.JavaScript Code: Here's a basic example of JavaScript code that you can use to retrieve the filter types for each column in a Data Grid 2:

var dataGridWidget = document.querySelector('.mx-name-dataGrid2');

if (dataGridWidget) {
    var columnHeaders = dataGridWidget.querySelectorAll('.mx-name-columnHeaders .mx-name-columnCaption');

    columnHeaders.forEach(function(columnHeader) {
        var columnName = columnHeader.textContent.trim();
        var filterTypeSelect = columnHeader.closest('.mx-name-container1').querySelector('.mx-name-dropdown');
        var filterType = filterTypeSelect.options[filterTypeSelect.selectedIndex].text;

        console.log('Column: ' + columnName + ', Filter Type: ' + filterType);
    });
}

 

This script assumes that the filter type dropdown for each column is a select element with the class mx-name-dropdown. You might need to adjust the class names and structure based on your specific implementation.

 

3.Execute the JavaScript: The JavaScript code needs to be executed when the Data Grid 2 is loaded or when filters are applied/changed. You can do this using the load or onchange events of the Data Grid 2 widget, or by triggering the execution through your own custom logic.

answered