Hi I looked for the docs to figure how to handle this question but the docs show the only solution for the type of the field like in the photo:
I wonder how to do this but for each field, without depending on the type of the field for example to the 'id' field I want only equals operator, and the field name I want the default operators.
1 Answer, 1 is accepted
Hi, Daniel,
It is possible to achieve the desired functionality by setting the ID field to a numeric filter and the products name to a text one like shown in the following example:
https://stackblitz.com/edit/react-e7c3sc-u4mnj2?file=app/main.jsx
However, the filter functionality currently works per type instead of per field. When changing the numeric filter, you will have to add all of the default operators, which are the following:
const filterOperators: {
'text': [
{ text: 'grid.filterContainsOperator', operator: 'contains' },
{ text: 'grid.filterNotContainsOperator', operator: 'doesnotcontain' },
{ text: 'grid.filterEqOperator', operator: 'eq' },
{ text: 'grid.filterNotEqOperator', operator: 'neq' },
{ text: 'grid.filterStartsWithOperator', operator: 'startswith' },
{ text: 'grid.filterEndsWithOperator', operator: 'endswith' },
{ text: 'grid.filterIsNullOperator', operator: 'isnull' },
{ text: 'grid.filterIsNotNullOperator', operator: 'isnotnull' },
{ text: 'grid.filterIsEmptyOperator', operator: 'isempty' },
{ text: 'grid.filterIsNotEmptyOperator', operator: 'isnotempty' }
],
'numeric': [
{ text: 'grid.filterEqOperator', operator: 'eq' },
{ text: 'grid.filterNotEqOperator', operator: 'neq' },
{ text: 'grid.filterGteOperator', operator: 'gte' },
{ text: 'grid.filterGtOperator', operator: 'gt' },
{ text: 'grid.filterLteOperator', operator: 'lte' },
{ text: 'grid.filterLtOperator', operator: 'lt' },
{ text: 'grid.filterIsNullOperator', operator: 'isnull' },
{ text: 'grid.filterIsNotNullOperator', operator: 'isnotnull' }
],
'date': [
{ text: 'grid.filterEqOperator', operator: 'eq' },
{ text: 'grid.filterNotEqOperator', operator: 'neq' },
{ text: 'grid.filterAfterOrEqualOperator', operator: 'gte' },
{ text: 'grid.filterAfterOperator', operator: 'gt' },
{ text: 'grid.filterBeforeOperator', operator: 'lt' },
{ text: 'grid.filterBeforeOrEqualOperator', operator: 'lte' },
{ text: 'grid.filterIsNullOperator', operator: 'isnull' },
{ text: 'grid.filterIsNotNullOperator', operator: 'isnotnull' }
],
'boolean': [
{ text: 'grid.filterEqOperator', operator: 'eq' }
]
}
Regards, Philip Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hi, Philip.
I don't understand how it is possible to achieve the functionality that I described in your answer.
I want to be able to choose which operator will be to each field in your example I want the operators I can select for the ID field to be only equal
and for the NAME field I can select all the text operators, this is possible? or at least for the specific field, I can remove some of the default operators?
Hello, Daniel,
Currently setting the operators for a field is not supported, since the functionality works per type of field and the operators depend on the type, instead of targeting a designated field. Based on the type of the field it is possible to exclude or include certain operators using the filterOperators prop, like shown in the updated example:
https://stackblitz.com/edit/react-e7c3sc-ho1tou?file=app/main.jsx
Where all of the text operators are included and passed to the grid.
We understand that this is not the same as filter operator per field, but it is the closest option to achieve setting a specific operator for the ID field and retaining the default operators for the name field.
Regards,
Philip
Hi, Daniel,
If you would like to see this functionality in a future release, feel free to submit a feature request in our feedback portal, that way based on the request popularity we will be able to add it:
https://feedback.telerik.com/kendo-react-ui
Regards,
Philip
Hi, Philip, I write you again about this issue.
so what do you recommend to do if I have a grid with 5 numeric filter columns and what that I need is to disable all the filter operators except the "is equal" one for only 2 of them?
Hi, Daniel,
Thank you for reaching out to us.
Currently, filterOperators can be set only for type and not for each field individually.
We see that you have already requested this functionality, once it recieves enough votes we can plan it's release accordingly:
https://feedback.telerik.com/kendo-react-ui/1548469-ability-to-choose-filter-operators-to-each-field
Regards,
Philip
Hi Philip.
I see that my feature request has not been planned to be implemented for a very long time.
there is no solution to this problem?
Hi Daniel,
The ETA for a Feedback item implementation depends on the popularity of the feature and then on its complexity. Each release our developers review the items in the portal and plan the most voted for implementation (if possible). The item linked in this thread is not very popular (it has only 2 votes) hence it has not been planned for implementation.
I hope the provided information sheds some light on how we prioritize the submitted feature requests. We will keep monitoring the popularity of this item and plan it accordingly.Ok, thanks.
but maybe for now you have some idea how can I solve this somehow?
Hi Daniel,
I am afraid that currently the filtering functionality of the Grid works per type instead of per field and there is no straight forward way to customize this.
The optimal workaround I can suggest you with the current implementation of the component is the one already provided by my colleague Filip, you can find it below:
https://stackblitz.com/edit/react-e7c3sc-ho1tou?file=app/main.jsx
Is it possible to do a custom operator and use it for example :
const filterOperators = {
text: [
{ text: 'grid.filterContainsOperator', operator: 'contains' },
{ text: 'grid.filterNotContainsOperator', operator: 'doesnotcontain' },
{ text: 'grid.filterEqOperator', operator: 'eq' },
{ text: 'grid.filterNotEqOperator', operator: 'neq' },
{ text: 'grid.filterStartsWithOperator', operator: 'startswith' },
{ text: 'grid.filterEndsWithOperator', operator: 'endswith' },
{ text: 'grid.filterIsNullOperator', operator: 'isnull' },
{ text: 'grid.filterIsNotNullOperator', operator: 'isnotnull' },
{ text: 'grid.filterIsEmptyOperator', operator: 'isempty' },
{ text: 'grid.filterIsNotEmptyOperator', operator: 'isnotempty' },
],
text2: [
{ text: 'grid.filterEqOperator', operator: 'eq' },
]
};
Hi Daniel,
Currently there are only 5 options for the filter cells: text, boolean, numeric, date and disabled filtering for the column - in order to define a custom filtering option you need to implement a custom filterCell.
You can find interesting discussion on the matter in the following issue:
https://github.com/telerik/kendo-react/issues/8
Hi, Vessy thank you I will check it.
Can you help me with another question please:
I use DropDownFilterMenu as my column menu filter and my question is how can I add the options to choose the operator like the rest of the filters? can you please provide an example of how to do that?
{
field:"validators",
title:t("Validators"),
columnMenu:(props, algorithmModes, dataIntegretyValidationModes,validators ) => <DropDownFilterMenu data={validators} defaultItem={"--Select Value--"} {...props} expanded={true} />,
},
Hi Daniel,
You can define the `filter` in the same way, but depending on your custom column rendering you might need to handle the filtering with some custom logic (adding additional buttons).
You can see how to use the GridColumnMenuCheckboxFilter component and create a custom filtering column menu in this sample: