let data = [
{
id: 1,
first_name: "The name",
tags: [{
id: "1",
name: "Renovation",
slug: "renovation"
},
{
id: "2",
name: "Chantier",
slug: "chantier"
}]
}
];
// Grid’s data source
this.gridData = [
{
id: 1, name: 'Kia Silverbrook', Work: [{
Tasks: "Labelling"
}]
},
{
id: 2, name: 'Simon R. Walmsley', Work: [{
Tasks: "Reviewing",
},
{
Tasks: "Allocating"
}]
},
{
id: 3, name: 'Paul Lapstun', Work: [{
Tasks: "Labelling",
},
{
Tasks: "Allocating"
}]
},
{
id: 4, name: 'Akira Nakazawa', Work: [{
Tasks: "Reviewing",
}]
},
{
id: 5, name: 'Gregory McAvoy', Work: [{
Tasks: "Marketing",
}],
},
]
// Overriding DataUtil equal method
DataUtil.fnOperators.equal = function (actual, expected, ignoreCase, ignoreAccent) {
if (Array.isArray(actual)) {
if (expected == "") {
return !actual.length;
}
return JSON.stringify(actual).includes(expected)
} else {
if (ignoreAccent) {
actual = DataUtil.ignoreDiacritics(actual);
expected = DataUtil.ignoreDiacritics(expected);
}
if (ignoreCase) {
return DataUtil.toLowerCase(actual) === DataUtil.toLowerCase(expected);
}
return actual === expected;
}
};
// Overriding DataUtil notequal method
DataUtil.fnOperators.notequal = function (actual, expected, ignoreCase, ignoreAccent) {
if (Array.isArray(actual)) {
if (expected == "") {
return actual.length;
}
return !JSON.stringify(actual).includes(expected)
} else {
if (ignoreAccent) {
actual = DataUtil.ignoreDiacritics(actual);
expected = DataUtil.ignoreDiacritics(expected);
}
return !DataUtil.fnOperators.equal(actual, expected, ignoreCase);
}
};
// Grid’s actionBegin event function
actionBegin(args) {
if (args.requestType === 'filterbeforeopen' && args.columnName === 'Work') {
// Modifying filter datasource
args.filterModel.options.dataSource = this.getDataSource();
}
getDataSource() {
var data = [];
var flag = true;
var lookup = {};
var Work = this.gridData.map(value => value.Work);
Work.forEach((arr) => {
arr.forEach((task) => {
if (!(task.Tasks in lookup)) {
data.push({ Work: task.Tasks });
lookup[task.Tasks] = true
}
})
if (!arr.length && flag) {
data.push({})
flag = false;
}
})
return data;
} |
{
"requiresCounts": true,
"where": [
{
"isComplex": true,
"ignoreAccent": false,
"condition": "and",
"predicates": [
{
"isComplex": true,
"ignoreAccent": false,
"condition": "or",
"predicates": [
{
"isComplex": false,
"field": "tags__slug",
"operator": "in",
"value": ["jambon"],
"ignoreCase": true,
"ignoreAccent": false
},
{
"isComplex": false,
"field": "tags__slug",
"operator": "in",
"value": ["test"],
"ignoreCase": true,
"ignoreAccent": false
}
]
}
]
}
],
"sorted": [
{
"name": "created_at",
"direction": "descending"
}
],
"params": {
"filter": {}
},
"filter": {},
"skip": 0,
"take": 12
}