How to Make Date Time Filter in the KendoReact Grid

0 Answers 444 Views
DateTimePicker Filter  General Discussions Grid
Daniel
Top achievements
Rank 1
Iron
Iron
Daniel asked on 31 Jan 2022, 05:39 PM

Hi.

I use Column Menu Filter in my data grids and I wonder how can I use the DateTime filter on date fields?

Daniel
Top achievements
Rank 1
Iron
Iron
commented on 01 Feb 2022, 08:52 AM

Ok Solved With filterUI props and DateTimePicker Component but now my problem is how to attach a dropdown to choose an operator like the rest of the column menu filter?
Konstantin Dikov
Telerik team
commented on 01 Feb 2022, 05:37 PM

Hello Daniel,

Using the filterUI is the right way for changing the default filter components. As for including the operators DropDownList components, you can take a look at the following KB article, where the operators are included in the custom filter:

Please give this a try and let us know if further questions arise.

Daniel
Top achievements
Rank 1
Iron
Iron
commented on 02 Feb 2022, 08:36 AM

Hi Konstantin.

Thanks, but in this example when I filter and change the default operator for example filter with the operator "is equal to" and some value and then open again the filter menu its back to the default operator "contains" and the value is empty, how can I make it consistent?

Konstantin Dikov
Telerik team
commented on 02 Feb 2022, 04:26 PM

Hi Daniel,

In order to set the changed operators you can use the filterUI properties and find the corresponding operator from the applied filters:

export const CustomFilterUI = (props) => {
  const operators = props.firstFilterProps.operators;
  const logic = props.logicData;
  const productNames = products.map((item) => {
    return item.ProductName;
  });
  const operator1 = props.firstFilterProps.operator;
  const operator2 = props.secondFilterProps.operator;
  const [state, setState] = React.useState({
    first: operator1
      ? operators.filter((i) => i.operator == operator1)[0]
      : operators[0],
    second: operator2
      ? operators.filter((i) => i.operator == operator2)[0]
      : operators[1],
  });

And here is the modified example:

Hope this helps.

No answers yet. Maybe you can help?

Tags
DateTimePicker Filter  General Discussions Grid
Asked by
Daniel
Top achievements
Rank 1
Iron
Iron
Share this question
or