当前位置: 首页 > news >正文

Blazor 虚拟滚动/瀑布流加载Table数据

@page "/virtualScrolling"
@using BlazorApp.Data<h3>Table 虚拟滚动行</h3>
<h4>Table 组件显示大数据时通常采用分页加载数据,还有一种虚拟行的技术类似手机滚动到底部时后台自动加载数据</h4><p>快速滚动时显示行占位,提升用户体验</p><p>PageItems:设置页大小,Height:设置Table的高度,ScrollMode="ScrollMode.Virtual"开启虚拟滚动功能</p><p>当前页大小: @PageCount</p><Table TItem="Foo" Height="300" PageItems="20" IsBordered="true" IsStriped="true" ScrollMode="ScrollMode.Virtual" OnQueryAsync="OnQueryAsync"><TableColumns><TableColumn @bind-Field="@context.DateTime" Width="180" /><TableColumn @bind-Field="@context.Name" /><TableColumn @bind-Field="@context.Address" Readonly="true" /><TableColumn @bind-Field="@context.Education" /><TableColumn @bind-Field="@context.Count" Editable="false" /><TableColumn @bind-Field="@context.Complete" /></TableColumns>
</Table>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using System.Net.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.Web.Virtualization;
using Microsoft.JSInterop;
using BlazorApp;
using BlazorApp.Shared;
using BootstrapBlazor.Components;
using BlazorApp.Data;
using System.Diagnostics.CodeAnalysis;namespace BlazorApp.Pages
{public partial class VirtualScrolling{[NotNull]private List<Foo>? DBList { get; set; }[NotNull]private int PageCount { get; set; }/// <summary>/// OnInitialized/// </summary>protected override void OnInitialized(){base.OnInitialized();//模拟数据库DBList = Foo.GenerateFoo(10000);}private async Task<QueryData<Foo>> OnQueryAsync(QueryPageOptions options){//控制加载数据,避免卡死await Task.Delay(200);//从数据库读取分页的总数int count = DBList.Count;//分页获取var items = DBList.Skip(options.StartIndex).Take(options.PageItems);PageCount = options.PageItems;//异步方法需要主动调用这个方法,告诉前台Blazor的状态已经改变StateHasChanged();return new QueryData<Foo>(){Items = items,TotalCount = count};}}
}

http://www.lryc.cn/news/215892.html

相关文章:

  • 数字化浪潮下,AI数字人融入多元化应用场景
  • JVM虚拟机:JVM的垃圾回收清除算法(GC)有哪些
  • 我应该删除低质量页面以提高Google排名吗?
  • 【实战Flask API项目指南】之六 数据库集成 SQLAlchemy
  • MFC网络通信-Udp服务端
  • 最简单且有效的msvcp140.dll丢失的解决方法,有效的解决msvcp140.dll丢失
  • HBase理论与实践-基操与实践
  • 内存管理设计精要
  • Java——StringBuffer与StringBuilder的区别
  • 基于深度学习的菠萝与果叶视觉识别及切断机构设计
  • springboot整合七牛云oss操作文件
  • 跨国传输的常见问题与对应解决方案
  • Git(七).git 文件夹瘦身,GitLab 永久删除文件
  • 多线程锁的升级原理是什么
  • 金山文档轻维表之删除所有行记录
  • 站坑站坑站坑站坑站坑
  • 在Vue中,你可以使用动态import()语法来动态加载组件
  • 金蝶云星空表单插件获取日期控件判空处理(代码示例)
  • 通过xshell传输文件到服务器
  • centos7.9编译安装python3.7.2
  • 【教3妹学编程-算法题】2913. 子数组不同元素数目的平方和 I
  • 是否会有 GPT-5 的发布?
  • 使用 Selenium Python 检查元素是否存在
  • const迭代器与模板构造函数
  • 在Qt中解决opencv的putText函数无法绘制中文的一种解决方法
  • 【Linux】第六站:Centos系统如何安装软件?
  • Istio 实战
  • 【Midjourney入门教程4】与AI对话,写好prompt的必会方法
  • 基于单片机的智能灭火小车设计
  • [Machine Learning][Part 7]神经网络的基本组成结构