Clearing the value of a DropDownList with inline clear "button"

2 Answers 2016 Views
DropDownList
Pieter
Top achievements
Rank 1
Iron
Iron
Pieter asked on 29 Jul 2021, 07:44 AM

Hi,

I noticed that the value of all DropDown components can be cleared with the inline clear "button", but not the DropDownList. Is there any way to get the same consistent behavior for the DropDownList so that it's inline with the rest of the DropDowns?

versus:

To be clear, I know that I can reset it by setting the value to "null", but I want to be able to do it via a "x" button.

2 Answers, 1 is accepted

Sort by
0
Krissy
Telerik team
answered on 29 Jul 2021, 10:40 AM

Hi Pieter,

Thank you for providing the images to help clarify. At the moment, there is a difference between the DropDowns due to the popularity and usability of the current designs.

Of course, being consistent accross all of them is a reasonable request and there has already been submitted a feauture request for this particular case:
https://feedback.telerik.com/kendo-react-ui/1511750-add-an-option-to-customize-the-filter-input-of-the-dropdowns 

The feature will be planned based on community interest. As a heads up, I've already added a vote on your behalf for this feature and we will continue to monitor the popularity of this case.

Additionally, I believe that this feature request could also be of interest for you and you can vote for it as well:
https://feedback.telerik.com/kendo-react-ui/1510454-make-look-and-behavior-of-multiselect-similar-to-combobox 

Hope this information is helpful.

Regards,
Krissy
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/.

0
Pieter
Top achievements
Rank 1
Iron
Iron
answered on 12 Aug 2021, 10:03 AM

For anyone stumbling across this question, I solved it by adding a custom valueRender:


 const valueRender = (element: React.ReactElement<HTMLSpanElement>, value: T) => {
      if (!value) {
        return element;
      }

      const children = [
          <span key={1} style={{overflow: "hidden", textOverflow: "ellipsis", flexGrow: 1}}>{element.props.children}</span>,
          <span key={2} className="k-icon k-clear-value k-i-close" role="button" tabIndex={-1} title="Clear" onClick={clearValue}></span>,
      ];

      return React.cloneElement(element, { ...element.props }, children);
    };

    const clearValue = (e: React.MouseEvent<HTMLSpanElement>) => {
      e.stopPropagation();
      e.preventDefault();

     // Do whatever you need to do to clear the value
    };

Tags
DropDownList
Asked by
Pieter
Top achievements
Rank 1
Iron
Iron
Answers by
Krissy
Telerik team
Pieter
Top achievements
Rank 1
Iron
Iron
Share this question
or