-
Notifications
You must be signed in to change notification settings - Fork 81
Added new kb article dropdownlist-add-clear-button #2820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
xristianstefanov
merged 6 commits into
master
from
new-kb-dropdownlist-add-clear-button-387f7be39f804b18b31066583ec4852b
Mar 18, 2025
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fe08700
Added new kb article dropdownlist-add-clear-button
071e90d
Update knowledge-base/dropdownlist-add-clear-button.md
xristianstefanov 1019076
Update knowledge-base/dropdownlist-add-clear-button.md
xristianstefanov 2578cee
Update knowledge-base/dropdownlist-add-clear-button.md
xristianstefanov 76d8562
Update knowledge-base/dropdownlist-add-clear-button.md
xristianstefanov 084d152
Update knowledge-base/dropdownlist-add-clear-button.md
xristianstefanov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| --- | ||
| title: How to Add a Clear Button inside DropDownList | ||
| description: Learn how to integrate a clear button within the DropDownList for Blazor to enable users to reset the selected value easily. | ||
| type: how-to | ||
| page_title: How to Add a Clear Button Inside the DropDownList for Blazor | ||
| slug: dropdownlist-kb-add-clear-button | ||
| tags: dropdownlist, clear, button, reset | ||
| res_type: kb | ||
| ticketid: 1680480, 1612125 | ||
| --- | ||
|
|
||
| ## Environment | ||
| <table> | ||
| <tbody> | ||
| <tr> | ||
| <td>Product</td> | ||
| <td>DropDownList for Blazor</td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
|
|
||
| ## Description | ||
|
|
||
| This knowledge base answers the following questions: | ||
|
|
||
| - How can I add a reset functionality to the [DropDownList for Blazor](slug:components/dropdownlist/overview)? | ||
| - Is it possible to integrate a clear button within the DropDownList for Blazor? | ||
| - What is the approach to clear the selected item in DropDownList for Blazor? | ||
|
|
||
| ## Solution | ||
|
|
||
| To add a clear button inside the DropDownList component, follow the steps below: | ||
|
|
||
| 1. Include CSS style to position the clear button within the DropDownList. | ||
| 2. Implement a method that resets the selected value upon clicking the clear button. | ||
|
|
||
| `````RAZOR | ||
| <style> | ||
| .reset-button { | ||
| margin-left: -3.5em; | ||
| z-index: 10000; | ||
| } | ||
| </style> | ||
|
|
||
| <TelerikDropDownList @bind-Value="@SelectedItem" | ||
| DefaultText="" | ||
| Data="@DropDownData" | ||
| Width="320px" | ||
| Id="country"> | ||
| <DropDownListSettings> | ||
| <DropDownListPopupSettings Height="auto" /> | ||
| </DropDownListSettings> | ||
| </TelerikDropDownList> | ||
|
|
||
| <TelerikButton Class="reset-button" | ||
| Size="sm" | ||
| Visible="@(SelectedItem != null)" | ||
| FillMode="@ThemeConstants.Button.FillMode.Flat" | ||
| ButtonType="ButtonType.Reset" | ||
| Icon="@SvgIcon.X" | ||
| OnClick="@HandleDropDownListReset"> | ||
| </TelerikButton> | ||
|
|
||
| @code { | ||
| protected string? SelectedItem { get; set; } | ||
xristianstefanov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| protected List<string> DropDownData = new List<string>() { "first", "second", "third" }; | ||
xristianstefanov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| private void HandleDropDownListReset() | ||
| { | ||
| SelectedItem = null; | ||
| } | ||
| } | ||
| ````` | ||
|
|
||
| ## See Also | ||
|
|
||
| - [Overview of the DropDownList for Blazor](slug:components/dropdownlist/overview) | ||
xristianstefanov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - [Overview of the DropDownList for Blazor](slug:components/button/overview) | ||
xristianstefanov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.