Skip to content

Commit 36b60a8

Browse files
loader integration enhancements (#208)
1 parent a46167a commit 36b60a8

File tree

2 files changed

+88
-24
lines changed

2 files changed

+88
-24
lines changed

common-features/loading-sign.md

Lines changed: 87 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Many times a component loads or saves data and that can take some time. To show
1414

1515
The Telerik components use the Telerik [Loader]({%slug loader-overview%}) and [LoaderContainer]({%slug loadercontainer-overview%}) components internally to match the theme and design.
1616

17-
The components add the busy indicator when they detect a slow-running `async` **data operation** (when it takes more than 120ms). For example, when the user inserts a record in the grid and the data service operation takes longer than that, there will be a loading indicator over the grid.
17+
The components add the busy indicator when they detect a slow-running `async` **data operation** (when it takes more than 600ms). For example, when the user inserts a record in the grid and the data service operation takes longer than that, there will be a loading indicator over the grid.
1818

1919
#### In this article:
2020

@@ -39,18 +39,18 @@ The following list shows the components that have a built-in loading sign for da
3939
4040
-->
4141

42-
* [**Grid**](https://demos.telerik.com/blazor-ui/grid/loading-animation) - a loading sign covers the entire component for slow data operations such as paging, filtering, sorting, grouping, expanding groups with load-on-demand; editing, inserting and deleting records. It is shown when the `OnRead` event is called.
42+
* [**Grid**](https://demos.telerik.com/blazor-ui/grid/loading-animation) - a loading sign covers the data portion of the component for slow data operations such as paging, filtering, sorting, grouping, expanding groups with load-on-demand; editing, inserting and deleting records. It is shown when the `OnRead` event is called.
4343

44-
* **ListView** - a loading sign covers the entire component for slow data operations such as editing, inserting and deleting records. It is also shown when the `OnRead` event is called.
44+
* **ListView** - a loading sign covers the data portion of the component for slow data operations such as editing, inserting and deleting records. It is also shown when the `OnRead` event is called.
4545

4646
<!--
4747
4848
* **MultiSelect** - while data is loading through the `OnRead` event, the dropdown is visible and new items are placeholders that are replaced with actual data when it arrives.
4949
-->
5050

51-
* **Scheduler** - a loading sign covers the entire component for slow data operations such as editing, inserting and deleting appointments.
51+
* **Scheduler** - a loading sign covers the data portion of the component for slow data operations such as editing, inserting and deleting appointments.
5252

53-
* **TreeList** - a loading sign covers the entire component for slow data operations such as editing, inserting and deleting records. Expanding items with load-on-demand shows a loading indicator next to the item while the `OnExpand` event is running.
53+
* **TreeList** - a loading sign covers the data portion of the component for slow data operations such as editing, inserting and deleting records. Expanding items with load-on-demand shows a loading indicator next to the item while the `OnExpand` event is running.
5454

5555
* **TreeView** - for expanding nodes with load-on-demand, a loading indicator is shown next to the item while the `OnExpand` event is running.
5656

@@ -351,34 +351,20 @@ Truly asynchronous operations will still allow for a loading sign - such as the
351351

352352
We believe that having a loading sign that tells the user something is happening improves the user experience. This is why this feature is enabled by default on all data bound components that perform data operations.
353353

354-
We understand, however, that you might want to disable this feature in some cases. At the moment, you can use CSS to hide the loading indicator HTML. If you would like another implementation (such as a dedicated setting or more settings for the loader panel in general, let us know on our <a href="https://feedback.telerik.com/blazor" target="_blank">feedback portal</a>).
354+
We understand, however, that you might want to disable this feature in some cases. You can disable the large loading container that overlays the data portion of the components by setting their `EnableLoaderContainer` parameter to `false`.
355355

356-
>caption Remove the loading animation from the grid with CSS
356+
>caption Remove the main loading animation from the grid with a parameter
357357
358358
````CSHTML
359-
@* The CSS rule hides the loading sign. If you want to disable it for all grids, remove the custom Class from the grid declaration and the CSS rule.
360-
In a similar fashion you can inspect the rendered HTML and target the element you want to hide for other components.
361-
Make sure to have the proper cascade so that you do not break other components on the page you do not intend to affect. *@
362-
363-
<style>
364-
.no-loader.k-grid .k-loader-container {
365-
display: none !important;
366-
}
367-
</style>
359+
@* The data operations (such as filtering, sorting, paging) are slow in this example, but there is no loading sign *@
368360
369-
<TelerikGrid Class="no-loader"
361+
<TelerikGrid EnableLoaderContainer="false"
370362
Data=@GridData TotalCount=@Total OnRead=@ReadItems
371363
[email protected] Sortable=true Pageable=true EditMode="@GridEditMode.Inline">
372364
<GridColumns>
373365
<GridColumn Field=@nameof(Employee.ID) />
374366
<GridColumn Field=@nameof(Employee.Name) Title="Name" />
375367
<GridColumn Field=@nameof(Employee.HireDate) Title="Hire Date" />
376-
<GridCommandColumn>
377-
<GridCommandButton Command="Save" Icon="save" ShowInEdit="true">Update</GridCommandButton>
378-
<GridCommandButton Command="Edit" Icon="edit">Edit</GridCommandButton>
379-
<GridCommandButton Command="Delete" Icon="delete">Delete</GridCommandButton>
380-
<GridCommandButton Command="Cancel" Icon="cancel" ShowInEdit="true">Cancel</GridCommandButton>
381-
</GridCommandColumn>
382368
</GridColumns>
383369
<GridToolBar>
384370
<GridCommandButton Command="Add" Icon="add">Add Employee</GridCommandButton>
@@ -440,6 +426,84 @@ Make sure to have the proper cascade so that you do not break other components o
440426
}
441427
````
442428

429+
There are some components that show small (inline) loading indicators, and you can hide those with CSS if you wish to remove them.
430+
431+
>caption How to hide inline loading signs with CSS (example with TreeView)
432+
433+
````CSHTML
434+
@* The CSS rule hides the loading sign. If you want to disable it for all treeviews, remove the custom Class from the treeview declaration and the CSS rule.
435+
In a similar fashion you can inspect the rendered HTML and target the element you want to hide for other components.
436+
Make sure to have the proper cascade so that you do not break other components on the page you do not intend to affect. *@
437+
438+
<style>
439+
.no-loading-indicator .k-treeview-item .k-loader {
440+
display:none;
441+
}
442+
</style>
443+
444+
<TelerikTreeView Class="no-loading-indicator"
445+
Data="@TreeViewData" OnExpand="@LoadChildren">
446+
</TelerikTreeView>
447+
448+
449+
@code {
450+
List<TreeViewItem> TreeViewData { get; set; }
451+
452+
protected override async Task OnInitializedAsync()
453+
{
454+
await LoadInitialData();
455+
}
456+
457+
async Task LoadInitialData()
458+
{
459+
List<TreeViewItem> roots = new List<TreeViewItem>();
460+
461+
roots.Add(new TreeViewItem
462+
{
463+
Text = "Category 1",
464+
HasChildren = true
465+
});
466+
467+
roots.Add(new TreeViewItem
468+
{
469+
Text = "Category 2",
470+
HasChildren = true
471+
});
472+
473+
TreeViewData = roots;
474+
}
475+
476+
async Task LoadChildren(TreeViewExpandEventArgs args)
477+
{
478+
TreeViewItem currItem = args.Item as TreeViewItem;
479+
if (args.Expanded && currItem.Items == null)
480+
{
481+
await Task.Delay(2000); // artificial delay to showcase the concept - no loading signs now
482+
483+
currItem.Items = new List<TreeViewItem>();
484+
485+
if (currItem.Text.Length > 15)
486+
{
487+
currItem.HasChildren = false;
488+
await InvokeAsync(StateHasChanged);
489+
return;
490+
}
491+
492+
currItem.Items = Enumerable.Range(1, 3).Select(x => new TreeViewItem { Text = $"{currItem.Text} - {x}", HasChildren = true }).ToList();
493+
}
494+
}
495+
496+
public class TreeViewItem
497+
{
498+
public string Text { get; set; }
499+
public List<TreeViewItem> Items { get; set; }
500+
public bool Expanded { get; set; }
501+
public bool HasChildren { get; set; }
502+
}
503+
}
504+
````
505+
506+
443507

444508
## Troubleshooting
445509

components/grid/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ The following list of resources provides examples for data binding a grid in var
9696

9797
### Loading Animation
9898

99-
When the user performs data operations in the grid, the grid will display a loading sign over itself when it detects a long-running operation (over 120ms). This improves the user experience so they know they have to wait for the action to complete, and also prevents repeated actions.
99+
When the user performs data operations in the grid, the grid will display a loading sign over itself when it detects a long-running operation (over 600ms). This improves the user experience so they know they have to wait for the action to complete, and also prevents repeated actions.
100100

101101
The operations include paging, filtering, sorting, grouping, expanding groups with load-on-demand; editing, inserting and deleting records.
102102

0 commit comments

Comments
 (0)