This example implements data filtering (remote and local) across DataGrid columns whose cells contain arrays of string values.
The DataGrid filters two collection columns against local data. Each cell in these columns displays data from the following sources:
- An array of strings.
- An array of objects. Each object contains a string field.
Both columns use columns[].calculateFilterExpression to implement custom filtering logic. The example defines a custom comparison function (selector) designed to filter values within each cell collection:
function calculateFilterExpression(filterValue, selectedFilterOperation, target) {
const column = this;
if (filterValue) {
const selector = (data) => {
const applyOperation = (arg1, arg2, op) => {
const normalizedArg1 = arg1.toLowerCase();
const normalizedArg2 = arg2.toLowerCase();
if (op === "=") return normalizedArg1 === normalizedArg2;
// ...
};
const values = extractDisplayValues
? column.calculateDisplayValue(data).toLowerCase().split(", ")
: column.calculateCellValue(data);
return !!values?.find((v) => applyOperation(v, filterValue, selectedFilterOperation));
};
return [selector, "=", true];
}
return this.defaultCalculateFilterExpression.apply(this, arguments);
}For remote filtering, the DataGrid processes one column. The example sets RemoteOperations to true, and the component displays data from an array of objects. Each of these objects contains a string field.
The example configures remote filtering in an ASP.NET Core server application (ServerApp). This server uses DevExtreme.AspNet.Data and calls RegisterBinaryExpressionCompiler to extend filter expression capabilities. Refer to the following file for implementation details: FilterByCollectionPropertyHelper.cs.
ServerApp includes two data controllers:
InMemoryDataController(default): Supplies data from in-memory variables defined in the ASP.NET Core server application. Use this controller for testing.DbDataController: Supplies data from a Microsoft SQL (MSSQL) Northwind database. Better suited for production environments.
- Server App
- Angular
- React
- Vue
- jQuery
- ASP.NET Core
(you will be redirected to DevExpress.com to submit your response)
