lundi 24 août 2020

Add checkboxes to Semantic UI's dropdown

I'm using Semantic UI's dropdown for a table.

The component is this:

import React from 'react';
import { Dropdown } from 'semantic-ui-react';

import './Dropdown.styles.scss';

export default ({ placeholder, options, onChange, name, className }) => (
  <Dropdown
    className={className}
    name={name}
    placeholder={placeholder}
    search
    selection
    options={options}
    onChange={onChange}
    clearable
    selectOnBlur={false}
  />
);

and it's used in another component:

const cityOptions = [ // the existing options
      { text: 'Paris', value: 'Paris' },
      { text: 'London', value: 'London' },
     ...
    ];

  searchHandlerCity = (event, data) => { // the method that filter the cities
    const { getCompanies } = this.props; 
    getCompanies({
      name: this.props.query.name,
      city: data.value,
    });
  }; 

    <Dropdown // the dropdown with the data
      className="hello-dropdown"
      placeholder="City"
      onChange={this.searchHandlerCity}
      options={cityOptions}
    />

enter image description here

I was wondering if it's possible to modify it, instead of selecting only one from the dropdown to have a chechbox near each line and being able to click on them which will also provide multiselect option.

The Checkbox from Semantic UI doesn't tell too much if this is possible.




Aucun commentaire:

Enregistrer un commentaire