-
Notifications
You must be signed in to change notification settings - Fork 81
kb(tabstrip): Add KB for loading all tabs by default #2659
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
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,87 @@ | ||
| --- | ||
| title: Render All TabStrip Tabs Initially | ||
| description: Learn how to initialize, load and render all tabs on page load in the Telerik TabStrip for Blazor. | ||
| type: how-to | ||
| page_title: How to Render All TabStrip Tabs By Default | ||
| slug: tabstrip-kb-load-all-tabs | ||
| tags: telerik, blazor, tabstrip | ||
| ticketid: 1673750, 1654667 | ||
| res_type: kb | ||
| --- | ||
|
|
||
| ## Environment | ||
|
|
||
| <table> | ||
| <tbody> | ||
| <tr> | ||
| <td>Product</td> | ||
| <td>TabStrip for Blazor</td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
|
|
||
| ## Description | ||
|
|
||
| This KB answers the following questions: | ||
|
|
||
| * How to preload the contents of all TabStrip tabs and keep it rendered in the DOM at all times? | ||
| * How to load and render all the content of a Telerik TabStrip for Blazor? | ||
| * How to access components in TabStrip tabs that haven't been opened by the user? | ||
|
|
||
| ## Solution | ||
|
|
||
| Even when [`PersistTabContent="true"`]({%slug tabstrip-persist-content%}), the TabStrip initializes and renders each tab container for the first time only after the user clicks on the respective tab to activate it. This improves the app performance. | ||
|
|
||
| In scenarios where all TabStrip tabs must render initially and be in the DOM at all times, use the following approach: | ||
|
|
||
| 1. Move the tab content outside the TabStrip. Use one HTML `<div>` to hold the contents of each tab. | ||
| 1. Hide the TabStrip tab container elements (`<div class="k-tabstrip-content">`) with a `display:none` CSS style. | ||
| 1. Toggle the `display` styles of the HTML `<div>`s in the [TabStrip `ActiveTabIndexChanged` event]({%slug tabstrip-events%}#activetabindexchanged). | ||
|
|
||
| >caption Render all TabStrip tabs initially | ||
|
|
||
| ````RAZOR | ||
| <TelerikTabStrip @bind-ActiveTabIndex="@ActiveTabIndex" | ||
| Class="empty-tabstrip"> | ||
| <TabStripTab Title="First Tab"> </TabStripTab> | ||
| <TabStripTab Title="Second Tab"> </TabStripTab> | ||
| <TabStripTab Title="Third Tab"> </TabStripTab> | ||
| </TelerikTabStrip> | ||
|
|
||
| <div class="tabstrip-containers k-tabstrip"> | ||
| <div class="@( $"k-tabstrip-content {GetTabActive(0)}" )"> | ||
| First Tab Content | ||
| </div> | ||
| <div class="@( $"k-tabstrip-content {GetTabActive(1)}" )"> | ||
| Second Tab Content | ||
| </div> | ||
| <div class="@( $"k-tabstrip-content {GetTabActive(2)}" )"> | ||
| Third Tab Content | ||
| </div> | ||
| </div> | ||
|
|
||
| <style> | ||
| /* hide built-in tab containers */ | ||
| .empty-tabstrip .k-tabstrip-content { | ||
| display: none !important; | ||
| } | ||
| /* adjust tab borders */ | ||
| .tabstrip-containers .k-tabstrip-content { | ||
| border-top-width: 0; | ||
| } | ||
| </style> | ||
|
|
||
| @code { | ||
| public int ActiveTabIndex { get; set; } | ||
|
|
||
| private string GetTabActive(int index) | ||
| { | ||
| return ActiveTabIndex == index ? "k-active" : string.Empty; | ||
| } | ||
| } | ||
| ```` | ||
|
|
||
| ## See Also | ||
|
|
||
| * [Persist TabStrip Tab Content]({%slug tabstrip-persist-content%}) | ||
| * [TabStrip Events]({%slug tabstrip-events%}) | ||
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.