C
C#2y ago
Amos

❔ Blazor Hosted - Client datatable with large dataset

I have a table component (using MudBlazor) which accesses the server-side API endpoint and pulls (currently) around 130k records. As you can imagine, too much for a client. 🙂 I need help and examples if possible on how I can implement client/server table pagination. Any help is appreciated, thanks! https://mudblazor.com/components/table#server-side-filtering,-sorting-and-pagination (I followed this, but I don't quite understand its implementation for server-side, it seems all client-side to me.)
12 Replies
realivanjxツ
realivanjxツ2y ago
do u have api for pagination in the first place? if not then u need to make them first
Amos
Amos2y ago
I have an endpoint, but it's just a simple fetch and return all. I think that's my main question, how do I go about doing that on the server-side endpoint?
realivanjxツ
realivanjxツ2y ago
do you know how to query your database to return n items from x? return 10 items from 100th entry for example
FusedQyou
FusedQyou2y ago
MudBlazor has documentation for the table component. It has a specific section for "Server Side Filtering, Sorting and Pagination" Solution: work off that, and you pass the TableState's Page and PageSize as query parameters. Your server will then skip Page * PageSize and take PageSize. Adjust as needed. Assuming you use EntityFramework, skip and take are the exact methods you need Regular SQL expressions are basically the same though
FusedQyou
FusedQyou2y ago
If you want my tip: the .NET team is working on their own table variant called quickgrid. I like this better. https://aspnet.github.io/quickgridsamples/
Intro
Samples using the QuickGrid component for Blazor.
Amos
Amos2y ago
Okay thanks both. 🙂 Should the skip/take reference be passed via url query? How do other people handle this?
FusedQyou
FusedQyou2y ago
url query is usually used
FusedQyou
FusedQyou2y ago
This is typescript, but you get the idea. This is how my methods usually look like.
FusedQyou
FusedQyou2y ago
PaginationRequest on the client. I defaulted to the first page, and 3 per page.
FusedQyou
FusedQyou2y ago
Usually your API will then return the total items in the database, and the actual result. Your paginator can then define the amount of pages by checking ceil(totalItems / itemsPerPage)
Amos
Amos2y ago
Much appreciated for the complete answer. 🙂 I'll give this a go, thanks for your time!
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ How do I cycle through different observable collections within the same collection view?My current plan is to do something like: ``` List <ObservableCollection<TodoItem>> allTodoItems✅ I'm trying to understand WPF's source code. What is a WeakReferenceWeakReference is a class that probably has applications other than in WPF (in particular, I'm trying❔ Shortcut for selecting multiple lines on windowsHi, I want to select only lines 146, 150 and 154 in my project in order to copy them, is there a sho✅ Token present on Get but missing on Post using IdentityPasted images to show autos with breakpoints. Code present on Get but missing on Post. I'm not sure ❔ Watch on screen area and reactHi. How can I do it? I need to "watch" on specfic screen area and when eg cursor is in this area app✅ The name does not exist in current context. (forms)I simply may be too dumb but i cannot wrap my head why is this an error.❔ Docker issues with dotnet restorePlease read my Stackoverflow post.... I have been working on this for a couple of days now I can't f✅ Mathematical ExpressionsHi, for my university assignment, I am required to add complex expressions alongside my variables. T✅ Window Forms.NET question..are all of the objects that are accessible from toolbox (window forms .NET) created by using deleg❔ UNITY When I manually execute 2 functions it works but not when executing them from 1 function.When I run Initialize() it only works the 2ND TIME (First time only runs DestroyCities(), Second tim