Search code examples
filterdropdownmultiple-columnsmulti-selectmui-datatable

MUI-DataTables, How to customize filter dropdown select with extra column containing icon


I am using MUI-DataTables (gregnb) and want to customize a multi-select dropdown in the filter tab, by adding an extra column to the dropdown.
Is it possible? Would it be in filteroptions.display? or customFilterListOptions (which I use to customize the text in the chip) and if so how please.

Thanks


Solution

  • I got it by: specifying filterType = 'custom' and returning Material-ui markup. i.e.

    filterType = 'custom';
    filterOptions = {
        names: getMyArray(),
        logic: (value, filters) => { ......
        },
         display: (filterList, onChange, index, column) => {
            return (
               <FormControl>
                  <InputLabel htmlFor="select-multiple-chip">Location</InputLabel>
                      <Select
                          className ={class1.A}
                          multiple
                          value={filterList[index]}
                          renderValue={(selected) => selected.join(", ")}
                          onChange={(event) => {
                          filterList[index] = event.target.value;
                          onChange(filterList[index], index, column);
                      }}
                      >                                                     
    
                      {locArr.map((name, name2) =>(
                          <MenuItem key={id} value={name}  className ={classesF.A}>
                              <Checkbox className ={classesF.D} />
                              <ListItemText primary={name}/>
                              <ListItemText primary={name2}/>
                         </MenuItem>
                     ))}
                </Select>
           </FormControl>
       );
    

    }