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.