How to apply initial value of GridColumn -> GridColumnMenuFilter?

1 Answer 119 Views
Filter  Grid
Mykola
Top achievements
Rank 1
Mykola asked on 05 Feb 2022, 08:31 AM

I need to set the initial filter value inside GridColumnMenuFilter.

 

The problem: initial value applies to filter under title but not apply to filter inside GridColumnMenuFilter.

 

Code example:


const initialFilter: CompositeFilterDescriptor = {
    logic: "and",
    filters: [
      {
        field: "isAdmin",
        operator: "eq",
        value: true,
      },
    ],
  };

  const GridColumnMenu = (props: GridColumnMenuProps): JSX.Element => {
  return (
    <div>
      <GridColumnMenuFilter {...props} expanded={true} hideSecondFilter />
    </div>
  );
};

 const columnProps = (
  field: string
) => {
  return {
    field: field,
    columnMenu: GridColumnMenu
  };
};

  <Grid           
        data={tableData.data}           
        filterable={true}
        filter={initialFilter}            
      >
    <GridColumn
       title={"Is Admin>"}
       {...columnProps("isAdmin")} />
    ...
 </Grid>

Thanks for any help.

1 Answer, 1 is accepted

Sort by
1
Accepted
Stefan
Telerik team
answered on 07 Feb 2022, 05:52 AM

Hello,

The ColumnFilter expects a CompositeFilter:

https://www.telerik.com/kendo-react-ui/components/dataquery/api/CompositeFilterDescriptor/

If that type of filter is set, the ColumMenu will be populated. I made an example showcasing that:

https://stackblitz.com/edit/react-oskaf4?file=app/main.jsx

Regards,
Stefan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Mykola
Top achievements
Rank 1
commented on 07 Feb 2022, 08:40 AM

Thanks, based on your example I'm updated my initial filter and now it's work fine.
Tags
Filter  Grid
Asked by
Mykola
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or