文章分類/

Infragistics|Ignite UI for Blazor|IgbDataGrid – 頁面最初顯示時捲動到指定行

尚無瀏覽量
2023-11-05 更新

infragistics log

IgbDataGrid 是一個已棄用的控制項。請改用IgbGrid 。如果您對如何使用IgbGrid實作有任何疑問,請聯絡我們的技術支援。

要在放置 IgbDataGrid 的頁面上初始顯示頁面(Razor 元件)時將 IgbDataGrid 提前捲動到指定行,可以使用以下程式碼。

@page "/"
...
...
...
@code {
    private IgbDataGrid _DataGridRef;

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            // IgbDataGrid コンポーネントが操作可能になるまで待つ
            await _DataGridRef.EnsureReady();

            // 例として、4,321 行目へスクロールさせる
            _DataGridRef.ScrollToRowByIndex(4321);
        }
    }
...

重點是:

・滾動 IgbDataGrid 的時機是呼叫頁面(Razor 元件)的OnAfterRenderAsync(bool firstRender)方法並且其參數(firstRender)為 true時。・滾動 IgbDataGrid 之前,IgbDataGrid 變得可操作。等待IgbDataGrid的EnsureRedy ( Until使用使用)的方法

補充

有關 Blazor 應用程式中 Razor 元件「生命週期」的更多信息,包括使用 OnAfterRenderAsync() 初始滾動 IgbDataGrid 的背景,另請參閱下面的官方文件網站。

https://docs.microsoft.com/ja-jp/aspnet/core/blazor/components/lifecycle?view=aspnetcore-6.0

很重要的一點

請注意,即使您不等待使用 IgbDataGrid 的 EnsureReady() 方法,它也可能會正常運作,這取決於綁定到 IgbDataGrid 的資料行數和程式執行環境的處理速度。 但是,根據時間和情況,可能會出現以下異常情況。

System.InvalidOperationException: cannot invoke method until main component is ready.

請注意,如果您不以這種方式使用 EnsureReady() 調整時序,則存在潛在問題。

快速跳轉目錄

✦ 群昱 AccessSoft 你的全面軟體解決方案 ✦

身為全球眾多知名軟體在台灣合作夥伴,歡迎諮詢你需要的軟體服務!

Picture of 軟體專家
軟體專家

群昱作為全球知名軟體推薦合作夥伴,致力於提供更多軟體解決方案給你!

更多軟體新知

立即詢價

請留下完整資訊,以便我們提供精確的服務內容給你。

詢價資訊