Comments (6)
Please supply us with reproduction code in the form of a project or repository.
We do not have capacity to craft or compose a reproduction for every issue that gets raised.
If no code or repository is provided, this issue will get closed automatically in 3 days
Help us to help you. Thanks
from fluentui-blazor.
`@page "/customer"
@rendermode @(new InteractiveAutoRenderMode(prerender:false))
@using System.Diagnostics
@Inject HttpClient _Http
@Inject NavigationManager _NavigationManager
<h1>@_ErorMsg</h1>
<FluentCard Width="100%" >
<h3>Customer</h3>
<FluentDataGrid ItemsProvider="@_customerProvider" ResizableColumns="false"
Style="width: 100%" Loading="true" Pagination="@_pagination">
<PropertyColumn Property="@(p=>p.name)" Sortable="true"
Filtered="!string.IsNullOrWhiteSpace(nameFilter)" Tooltip="true" Title="Name">
<ColumnOptions >
<div class="search-box">
<FluentSearch type="search" Autofocus=true @bind-Value="nameFilter"
@oninput="HandleCountryFilter" @bind-Value:after="HandleClear" Placeholder="Name"/>
</div>
</ColumnOptions>
</PropertyColumn>
<PropertyColumn Property="@(c => c.phone)" Sortable="true" Class="multiline-text"/>
<PropertyColumn Property="@(c => c.address)" Sortable="true" Class="multiline-text"/>
</FluentDataGrid>
<FluentPaginator State="@_pagination" >
<SummaryTemplate >
Total rows : <strong>@((_pagination.TotalItemCount ?? 0).ToString("N0"))</strong>
<p>Time to load : @_loadingTime</p>
</SummaryTemplate>
<PaginationTextTemplate>
<strong>@((_pagination.CurrentPageIndex + 1).ToString("N0"))</strong> of <strong>@((_pagination.LastPageIndex + 1).Value.ToString("N0"))</strong>
</PaginationTextTemplate>
</FluentPaginator>
</FluentCard>
`
`@code {
PaginationState _pagination = new PaginationState { ItemsPerPage = 10 };
string? nameFilter = null;
private string _loadingTime { get; set; }
private string _ErorMsg { get; set; }
GridItemsProvider<Shared.Models.Customer>? _customerProvider;
protected override async Task OnInitializedAsync()
{
await LoadData();
}
private async Task LoadData()
{
_customerProvider = async req =>
{
Stopwatch _stopwatch =Stopwatch.StartNew();
// Construct the URL with query parameters
bool? sortingByAscending = req.SortByAscending!;
string? column = string.Empty;
if (req.SortByColumn is not null)
{
column = req.SortByColumn!.Title;
}
string apiUrl = $"{_NavigationManager.BaseUri}api/Customer";
string queryParameters =
$"?skip={req.StartIndex}&take={req.Count}&sortingByAscending={sortingByAscending}&column={column.ToLower()}";
Console.WriteLine("sardar url : "+queryParameters);
if (!string.IsNullOrEmpty(nameFilter))
{
queryParameters += $"&where={Uri.EscapeDataString(nameFilter)}";
}
string fullUrl = apiUrl + queryParameters;
var response = await _Http.GetFromJsonAsync<PaginationDTO.MyPaginationDTO>( fullUrl);
_stopwatch.Stop();
TimeSpan loadingTime2 = _stopwatch.Elapsed;
_loadingTime = string.Format("{0:D2}h:{1:D2}m:{2:D2}s:{3:D3}ms",
loadingTime2.Hours, loadingTime2.Minutes, loadingTime2.Seconds, loadingTime2.Milliseconds);
// Check if response is successful and contains data
if (response != null && response.customers != null)
{
if (response.customers.Count <= 0)
{
return GridItemsProviderResult.From(Array.Empty<Shared.Models.Customer>(), 0);
}
else
{
return GridItemsProviderResult.From(items: response.customers, totalItemCount: response.totalCount);
}
}
else
{
return GridItemsProviderResult.From(Array.Empty<Shared.Models.Customer>(), 0);
}
};
}
private async Task HandleCountryFilter(ChangeEventArgs args)
{
if (args.Value is string value)
{
nameFilter = value;
}
await LoadData();
}
private async Task HandleClear()
{
if (string.IsNullOrWhiteSpace(nameFilter))
{
nameFilter = string.Empty;
await LoadData();
}
}
}`
from fluentui-blazor.
Hi Sadar,
Can't run this code. Don't have Shared.Models.Customer
and this is also not working:
var response = await _Http.GetFromJsonAsync<PaginationDTO.MyPaginationDTO>( fullUrl);
But looking at your original issue, I think it is not a really good idea to use Virtualization and Pagination together. Think you can better do an 'on-demand' loading per page requested with Pagination.
See the DataGrid Custom Paging example on how you can create your own buttons and hook into the handlers.
from fluentui-blazor.
no if you look at my code for every new page I request a new http request for the API and it works fine but when I have 1M Record and sorting it take 700ms for each page. So for better user experience I want virtualize it or showing a nice loading at top of the DataGrid. if you look at this MudBlazor example you will understand what I mean.
MudBlazor Example
from fluentui-blazor.
That MudBlazor example has nothing to do with Virtualize. It determines which records to show on a page by doing:
pagedData = data.Skip(state.Page * state.PageSize).Take(state.PageSize).ToArray();
So returning just the exact rows that should be shown on a page. I don't think this is a component issue but more a general paging/sorting of a large data set problem.
from fluentui-blazor.
Closing due to no repro code provided
from fluentui-blazor.
Related Issues (20)
- fix: _tabs clear in fluent tabs HOT 2
- Introduce `Microsoft.FluentUI.AspNetCore.Components.DataGrid.ODataAdapter` for OData Support HOT 1
- The calendar component doesn't display properly in the card component HOT 1
- FluentSelect's SelectedOptionChanged triggered twice with different values HOT 2
- How to implement a tree select HOT 1
- feat: improvement of nav menu placement in header when in mobile view. HOT 5
- [FluentSelect] Missing icon on selected option HOT 5
- Invisible overflow in FluentGrid with large content which exceeds the content container HOT 4
- Issues in Fluent Autocomplete and Fluent Dialog controls HOT 2
- fix: AppBar missing some top padding on the popover for smaller views
- fix: AppBar shows active menu apps for onClick with `href="@(null)"` HOT 2
- feat: display error when MaximumFileSize is exceeded HOT 1
- docs: fix Many Items in Autocomplete HOT 9
- docs: How to prevent cutting off values in Data Grid? HOT 5
- How to add delay to Autocomplete search? HOT 1
- [FlunetDatagird] in [Safari v17.4.1 ] HOT 5
- fix: System.ArgumentNullException in MessageService.ShowMessageBar HOT 5
- fix: [Nested Tree View Styling] in [FluentDialog] HOT 2
- Fluent DataGrid in dark mode, cannot read the text when row is highlighted HOT 6
- FluentNavLink - When Href is specified the Disabled link color is not applied HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluentui-blazor.