-
Notifications
You must be signed in to change notification settings - Fork 81
kb(Dialog): Add KB for predefined dialog's width #2430
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
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
89 changes: 89 additions & 0 deletions
89
knowledge-base/dialog-dialogfactory-alert-confirm-prompt-width.md
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,89 @@ | ||
| --- | ||
| title: Set Width to Predefined Telerik Dialogs | ||
| description: Learn how to set width to predefined Telerik Dialogs such as alert, confirm and prompt modal popups. The width can be fixed or a percentage of the browser window's viewport. | ||
| type: how-to | ||
| page_title: How to Set Width to Predefined Telerik Dialogs | ||
| slug: dialog-kb-dialogfactory-alert-confirm-prompt-width | ||
| tags: telerik, blazor, dialog, css, styling | ||
| ticketid: 1667334 | ||
| res_type: kb | ||
| --- | ||
|
|
||
| ## Environment | ||
|
|
||
| <table> | ||
| <tbody> | ||
| <tr> | ||
| <td>Product</td> | ||
| <td>Dialog for Blazor</td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
|
|
||
| ## Description | ||
|
|
||
| This KB answers the following questions: | ||
|
|
||
| * How to specify a `width` style to the predefined Telerik Blazor Dialogs, such as `AlertAsync()`? | ||
| * How to apply dimensions to modal popups that are used through the Telerik `DialogFactory` cascading parameter? | ||
| * How to define a width of predefined dialogs that are a percentage of the browser window viewport? | ||
|
|
||
| ## Solution | ||
|
|
||
| All [Telerik Blazor Dialogs]({%slug dialog-overview%}) render a `k-dialog` CSS class. In addition, the [predefined dialogs]({%slug dialog-predefined%}) render a `k-alert` CSS class. Use this distinguishing CSS class to target popups that are generated by the Telerik `DialogFactory` and apply CSS styles. | ||
|
|
||
| >caption Set width to Telerik Blazor DialogFactory modal popups | ||
|
|
||
| ````CSHTML | ||
| <TelerikButton OnClick="@( () => DialogVisible = true )">Show Dialog</TelerikButton> | ||
|
|
||
| <TelerikButton OnClick="@ShowDialogFactoryPopup">Show DialogFactory Alert</TelerikButton> | ||
|
|
||
| <TelerikDialog @bind-Visible="@DialogVisible" | ||
| Width="33vw" | ||
| ButtonsLayout="@DialogButtonsLayout.End"> | ||
| <DialogTitle> | ||
| Dialog Component | ||
| </DialogTitle> | ||
| <DialogContent> | ||
| <p>This Dialog is 33vw wide at all times.</p> | ||
| </DialogContent> | ||
| <DialogButtons> | ||
| <TelerikButton ThemeColor="@ThemeConstants.Button.ThemeColor.Primary" | ||
| OnClick="@( () => DialogVisible = false )">OK</TelerikButton> | ||
| </DialogButtons> | ||
| </TelerikDialog> | ||
|
|
||
| <style> | ||
| /* This CSS rule will affect only DialogFactory popups */ | ||
| .k-dialog.k-alert { | ||
| min-width: 300px !important; /* overrides an inline style */ | ||
| width: 33vw; | ||
| max-width: 500px; | ||
| } | ||
| </style> | ||
|
|
||
| @code { | ||
| [CascadingParameter] | ||
| public DialogFactory? TelerikDialogs { get; set; } | ||
|
|
||
| private bool DialogVisible { get; set; } | ||
|
|
||
| private async Task ShowDialogFactoryPopup() | ||
| { | ||
| if (TelerikDialogs != null) | ||
| { | ||
| await TelerikDialogs.AlertAsync(@"This Dialog is 33vw wide, but with min/max restrictions. | ||
| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam ultricies congue dolor vel aliquet. | ||
| Nunc ac enim neque. Suspendisse facilisis porta laoreet. | ||
| Sed suscipit mauris lectus, ut porttitor velit porta vitae. | ||
| Suspendisse potenti. Quisque auctor ac ante at egestas.", "Alert Dialog"); | ||
| } | ||
| } | ||
| } | ||
| ```` | ||
|
|
||
| ## See Also | ||
|
|
||
| * [Predefined Telerik Dialogs]({%slug dialog-predefined%}) | ||
| * [Dialog Component Overview]({%slug dialog-overview%}) | ||
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.