Blazor Tree Grid 行のピン固定
Blazor Tree Grid の Ignite UI for Blazor 行ピン固定機能を使用すると、1 つまたは複数の行をグリッドの上部または下部にピン固定できます。行ピン固定を使用すると、エンドユーザーは特定の順序で行をピン固定し、IgbTreeGrid
を垂直にスクロールしても常に表示される特別な領域に行を複製できます。Blazor Tree Grid には組み込みの行ピン固定 UI が含まれており、Tree Grid のコンテキストで IgbActionStrip
コンポーネントを初期化することで有効になります。その他、カスタム UI を定義し、行のピン固定 API を介して行のピン固定状態を変更できます。
Blazor Tree Grid 行ピン固定の例
using System;
using System.Collections.Generic;
public class EmployeesNestedTreeDataItem
{
public double Age { get; set; }
public string HireDate { get; set; }
public double ID { get; set; }
public string Name { get; set; }
public string Phone { get; set; }
public bool OnPTO { get; set; }
public double ParentID { get; set; }
public string Title { get; set; }
}
public class EmployeesNestedTreeData
: List<EmployeesNestedTreeDataItem>
{
public EmployeesNestedTreeData()
{
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 55,
HireDate = @"2008-03-20",
ID = 1,
Name = @"Johnathan Winchester",
Phone = @"0251-031259",
OnPTO = false,
ParentID = -1,
Title = @"Development Manager"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 42,
HireDate = @"2014-01-22",
ID = 4,
Name = @"Ana Sanders",
Phone = @"(21) 555-0091",
OnPTO = true,
ParentID = -1,
Title = @"CEO"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 49,
HireDate = @"2014-01-22",
ID = 18,
Name = @"Victoria Lincoln",
Phone = @"(071) 23 67 22 20",
OnPTO = true,
ParentID = -1,
Title = @"Accounting Manager"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 61,
HireDate = @"2010-01-01",
ID = 10,
Name = @"Yang Wang",
Phone = @"(21) 555-0091",
OnPTO = false,
ParentID = -1,
Title = @"Localization Manager"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 43,
HireDate = @"2011-06-03",
ID = 3,
Name = @"Michael Burke",
Phone = @"0452-076545",
OnPTO = true,
ParentID = 1,
Title = @"Senior Software Developer"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 29,
HireDate = @"2009-06-19",
ID = 2,
Name = @"Thomas Anderson",
Phone = @"(14) 555-8122",
OnPTO = false,
ParentID = 1,
Title = @"Senior Software Developer"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 31,
HireDate = @"2014-08-18",
ID = 11,
Name = @"Monica Reyes",
Phone = @"7675-3425",
OnPTO = false,
ParentID = 1,
Title = @"Software Development Team Lead"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 35,
HireDate = @"2015-09-17",
ID = 6,
Name = @"Roland Mendel",
Phone = @"(505) 555-5939",
OnPTO = false,
ParentID = 11,
Title = @"Senior Software Developer"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 44,
HireDate = @"2009-10-11",
ID = 12,
Name = @"Sven Cooper",
Phone = @"0695-34 67 21",
OnPTO = true,
ParentID = 11,
Title = @"Senior Software Developer"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 44,
HireDate = @"2014-04-04",
ID = 14,
Name = @"Laurence Johnson",
Phone = @"981-443655",
OnPTO = false,
ParentID = 4,
Title = @"Director"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 25,
HireDate = @"2017-11-09",
ID = 5,
Name = @"Elizabeth Richards",
Phone = @"(2) 283-2951",
OnPTO = true,
ParentID = 4,
Title = @"Vice President"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 39,
HireDate = @"2010-03-22",
ID = 13,
Name = @"Trevor Ashworth",
Phone = @"981-443655",
OnPTO = true,
ParentID = 5,
Title = @"Director"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 44,
HireDate = @"2014-04-04",
ID = 17,
Name = @"Antonio Moreno",
Phone = @"(505) 555-5939",
OnPTO = false,
ParentID = 18,
Title = @"Senior Accountant"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 50,
HireDate = @"2007-11-18",
ID = 7,
Name = @"Pedro Rodriguez",
Phone = @"035-640230",
OnPTO = false,
ParentID = 10,
Title = @"Senior Localization Developer"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 27,
HireDate = @"2016-02-19",
ID = 8,
Name = @"Casey Harper",
Phone = @"0342-023176",
OnPTO = true,
ParentID = 10,
Title = @"Senior Localization"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 25,
HireDate = @"2017-11-09",
ID = 15,
Name = @"Patricia Simpson",
Phone = @"069-0245984",
OnPTO = false,
ParentID = 7,
Title = @"Localization Intern"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 39,
HireDate = @"2010-03-22",
ID = 9,
Name = @"Francisco Chang",
Phone = @"(91) 745 6200",
OnPTO = false,
ParentID = 7,
Title = @"Localization Intern"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 25,
HireDate = @"2018-03-18",
ID = 16,
Name = @"Peter Lewis",
Phone = @"069-0245984",
OnPTO = true,
ParentID = 7,
Title = @"Localization Intern"
});
}
}
csusing System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using IgniteUI.Blazor.Controls; // for registering Ignite UI modules
namespace Infragistics.Samples
{
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
// registering Ignite UI modules
builder.Services.AddIgniteUIBlazor(
typeof(IgbInputModule),
typeof(IgbPropertyEditorPanelModule),
typeof(IgbTreeGridModule),
typeof(IgbActionStripModule)
);
await builder.Build().RunAsync();
}
}
}
cs
@using IgniteUI.Blazor.Controls
@inject IJSRuntime JS
<div class="container vertical ig-typography">
<div class="options vertical">
<IgbPropertyEditorPanel
DescriptionType="WebTreeGrid"
IsHorizontal="true"
IsWrappingEnabled="false"
Name="propertyEditorPanel1"
@ref="propertyEditorPanel1">
<IgbPropertyEditorPropertyDescription
Name="rowPinningEditor"
@ref="rowPinningEditor"
ValueType="PropertyEditorValueType.EnumValue"
Label="Row Pinning toggle"
DropDownNames="@(new string[] { "Top", "Bottom" })"
DropDownValues="@(new string[] { "Top", "Bottom" })"
ChangedScript="WebGridSetRowPinning">
</IgbPropertyEditorPropertyDescription>
</IgbPropertyEditorPanel>
</div>
<div class="container vertical fill">
<IgbTreeGrid
AutoGenerate="false"
Id="treeGrid"
Name="treeGrid"
@ref="treeGrid"
Data="EmployeesNestedTreeData"
RowEditable="true"
PrimaryKey="ID"
ForeignKey="ParentID"
CellSelection="GridSelectionMode.None"
RenderedScript="WebTreeGridPinRowOnRendered"
Pinning="PinningConfig1">
<IgbColumn
Field="Name"
Header="Full Name">
</IgbColumn>
<IgbColumn
Field="Age"
DataType="GridColumnDataType.Number">
</IgbColumn>
<IgbColumn
Field="Title">
</IgbColumn>
<IgbColumn
Field="HireDate"
DataType="GridColumnDataType.Date">
</IgbColumn>
<IgbActionStrip
Name="actionStrip"
@ref="actionStrip">
<IgbGridPinningActions
>
</IgbGridPinningActions>
</IgbActionStrip>
</IgbTreeGrid>
</div>
</div>
@code {
private Action BindElements { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
{
var propertyEditorPanel1 = this.propertyEditorPanel1;
var rowPinningEditor = this.rowPinningEditor;
var treeGrid = this.treeGrid;
var actionStrip = this.actionStrip;
this.BindElements = () => {
propertyEditorPanel1.Target = this.treeGrid;
};
this.BindElements();
}
private IgbPropertyEditorPanel propertyEditorPanel1;
private IgbPropertyEditorPropertyDescription rowPinningEditor;
private IgbTreeGrid treeGrid;
private IgbPinningConfig _pinningConfig1 = null;
public IgbPinningConfig PinningConfig1
{
get
{
if (this._pinningConfig1 == null)
{
var pinningConfig1 = new IgbPinningConfig();
pinningConfig1.Rows = RowPinningPosition.Top;
this._pinningConfig1 = pinningConfig1;
}
return this._pinningConfig1;
}
}
private IgbActionStrip actionStrip;
private EmployeesNestedTreeData _employeesNestedTreeData = null;
public EmployeesNestedTreeData EmployeesNestedTreeData
{
get
{
if (_employeesNestedTreeData == null)
{
_employeesNestedTreeData = new EmployeesNestedTreeData();
}
return _employeesNestedTreeData;
}
}
}
razor
igRegisterScript("WebGridSetRowPinning", (sender, evtArgs) => {
var item = sender;
var newVal = item.primitiveValue;
var grid = document.getElementById("treeGrid") || document.getElementById("grid");
grid.pinning.rows = newVal === "Top" ? 0 : 1;
}, false);
igRegisterScript("WebTreeGridPinRowOnRendered", (event) => {
var treeGrid = document.getElementById("treeGrid") || document.getElementById("grid");
treeGrid.data = [...treeGrid.data];
treeGrid.pinRow(1);
treeGrid.pinRow(11);
}, false);
js/*
CSS styles are loaded from the shared CSS file located at:
https://static.infragistics.com/xplatform/css/samples/
*/
css
このサンプルが気に入りましたか? 完全な Ignite UI for Blazorツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
行のピン固定 UI
組み込みの行ピン固定 UI は、IgbGridPinningActions
コンポーネントと IgbActionStrip
コンポーネントを追加することで有効になります。アクション ストリップは、行にカーソルを合わせると自動的に表示され、表示されている行の状態に基づいてピン固定またはピン固定解除ボタンのアイコンが表示されます。ピン固定された行のコピーをビューにスクロールする追加のアクションがピン固定された行ごとに表示されます。
<IgbTreeGrid Width="100%"
Height="100%"
PrimaryKey="Key"
AutoGenerate=true
Data=northwindEmployees
RowEditable=true>
<IgbColumn Field="ID" Editable=false></IgbColumn>
<IgbColumn Field="ContactName"></IgbColumn>
<IgbColumn Field="ContactTitle"></IgbColumn>
<IgbColumn Field="City" Sortable=true></IgbColumn>
<IgbColumn Field="CompanyName" Sortable=true></IgbColumn>
<IgbColumn Field="Fax" Sortable=true></IgbColumn>
<IgbColumn Field="Address" Sortable=true></IgbColumn>
<IgbColumn Field="PostalCode" Sortable=true></IgbColumn>
<IgbColumn Field="Country" Sortable=true></IgbColumn>
<IgbColumn Field="Phone" Sortable=true></IgbColumn>
<IgbActionStrip>
<IgbGridPinningActions></IgbGridPinningActions>
<IgbGridEditingActions></IgbGridEditingActions>
</IgbActionStrip>
</IgbTreeGrid>
razor
行のピン固定 API
行のピン固定は Row
の Pinned
入力によって制御されます。デフォルトでピン固定行は IgbTreeGrid
の上側に固定して描画され、IgbTreeGrid
本体のピン固定されていない行は垂直スクロールされます。
this.Grid.PinRowAsync("ALFKI", 0);
razor
IgbTreeGrid
の PinRow
または UnpinRow
メソッドを使用して ID によって行をピン固定またはピン固定解除できます。
this.Grid.PinRowAsync("ALFKI", 0);
this.Grid.UnpinRowAsync("ALFKI");
razor
注: 行の ID は、グリッドの PrimaryKey
またはレコード インスタンス自体によって定義される主キー値です。両方のメソッドは操作に成功したかどうかを示すブール値を返します。よくある失敗の原因に行がすでにその状態になっていることがあります。
行は、最後にピンされた行の下にピン固定されます。ピン固定行の順序を変更するには、RowPinning
イベントでイベント引数の InsertAtIndex
プロパティを適切な位置インデックスに変更します。
<IgbTreeGrid Width="100%"
Id="grid"
RowPinningScript="rowPinningHandler"
Height="100%"
PrimaryKey="Key"
AutoGenerate="true"
Data="northwindEmployees">
</IgbTreeGrid>
razor
*** In JavaScript ***
function rowPinningHandler(event) {
event.detail.insertAtIndex = 0;
}
igRegisterScript("rowPinningHandler", rowPinningHandler, false);
razor
ピン固定の位置
Pinning
設定オプションを使用して、行のピン固定の位置を変更できます。ピン固定の位置を Top または Bottom のいずれかに設定できます。
Bottom に設定すると、行がピン固定されていない行の後に、グリッドの一番下にレンダリングされます。ピン固定されていない行は垂直にスクロールできますが、ピン固定された行は下側に固定されます。
<IgbTreeGrid Id="grid"
Width="100%"
Height="100%"
Pinning=PinningConfig
PrimaryKey="Key"
AutoGenerate=true
Data=northwindEmployees>
</IgbTreeGrid>
@code {
public string Key = "ID";
private Northwind.EmployeesType[] northwindEmployees = Array.Empty<Northwind.EmployeesType>();
public IgbPinningConfig PinningConfig = new IgbPinningConfig()
{
Rows = RowPinningPosition.Bottom
};
protected override async Task OnInitializedAsync()
{
northwindEmployees = await this.northwindService.GetEmployees() ?? northwindEmployees;
}
}
razor
カスタム行ピン固定 UI
カスタム UI を定義し、関連する API を介して行のピン状態を変更できます。
アイコン付きの追加の列による
アクション ストリップの代わりに、すべての行にピンのアイコンを表示し、エンドユーザーが特定の行のピン状態をクリックして変更できます。 カスタム アイコンを含むセル テンプレートの列を追加することで実行できます。
<IgbColumn Width="70px" BodyTemplateScript="WebGridRowPinCellTemplate"/>
// In Javascript
igRegisterScript("WebGridRowPinCellTemplate", (ctx) => {
var html = window.igTemplating.html;
window.toggleRowPin = function toggleRowPin(index) {
var grid = document.getElementsByTagName("igc-grid")[0];
grid.getRowByIndex(index).pinned = !grid.getRowByIndex(index).pinned;
}
const index = ctx.cell.id.rowIndex;
return html`<div>
<span onpointerdown='toggleRowPin("${index}")'>📌</span>
</div>`;
}, false);
razor
デモ
using System;
using System.Collections.Generic;
public class EmployeesNestedTreeDataItem
{
public double Age { get; set; }
public string HireDate { get; set; }
public double ID { get; set; }
public string Name { get; set; }
public string Phone { get; set; }
public bool OnPTO { get; set; }
public double ParentID { get; set; }
public string Title { get; set; }
}
public class EmployeesNestedTreeData
: List<EmployeesNestedTreeDataItem>
{
public EmployeesNestedTreeData()
{
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 55,
HireDate = @"2008-03-20",
ID = 1,
Name = @"Johnathan Winchester",
Phone = @"0251-031259",
OnPTO = false,
ParentID = -1,
Title = @"Development Manager"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 42,
HireDate = @"2014-01-22",
ID = 4,
Name = @"Ana Sanders",
Phone = @"(21) 555-0091",
OnPTO = true,
ParentID = -1,
Title = @"CEO"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 49,
HireDate = @"2014-01-22",
ID = 18,
Name = @"Victoria Lincoln",
Phone = @"(071) 23 67 22 20",
OnPTO = true,
ParentID = -1,
Title = @"Accounting Manager"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 61,
HireDate = @"2010-01-01",
ID = 10,
Name = @"Yang Wang",
Phone = @"(21) 555-0091",
OnPTO = false,
ParentID = -1,
Title = @"Localization Manager"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 43,
HireDate = @"2011-06-03",
ID = 3,
Name = @"Michael Burke",
Phone = @"0452-076545",
OnPTO = true,
ParentID = 1,
Title = @"Senior Software Developer"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 29,
HireDate = @"2009-06-19",
ID = 2,
Name = @"Thomas Anderson",
Phone = @"(14) 555-8122",
OnPTO = false,
ParentID = 1,
Title = @"Senior Software Developer"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 31,
HireDate = @"2014-08-18",
ID = 11,
Name = @"Monica Reyes",
Phone = @"7675-3425",
OnPTO = false,
ParentID = 1,
Title = @"Software Development Team Lead"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 35,
HireDate = @"2015-09-17",
ID = 6,
Name = @"Roland Mendel",
Phone = @"(505) 555-5939",
OnPTO = false,
ParentID = 11,
Title = @"Senior Software Developer"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 44,
HireDate = @"2009-10-11",
ID = 12,
Name = @"Sven Cooper",
Phone = @"0695-34 67 21",
OnPTO = true,
ParentID = 11,
Title = @"Senior Software Developer"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 44,
HireDate = @"2014-04-04",
ID = 14,
Name = @"Laurence Johnson",
Phone = @"981-443655",
OnPTO = false,
ParentID = 4,
Title = @"Director"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 25,
HireDate = @"2017-11-09",
ID = 5,
Name = @"Elizabeth Richards",
Phone = @"(2) 283-2951",
OnPTO = true,
ParentID = 4,
Title = @"Vice President"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 39,
HireDate = @"2010-03-22",
ID = 13,
Name = @"Trevor Ashworth",
Phone = @"981-443655",
OnPTO = true,
ParentID = 5,
Title = @"Director"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 44,
HireDate = @"2014-04-04",
ID = 17,
Name = @"Antonio Moreno",
Phone = @"(505) 555-5939",
OnPTO = false,
ParentID = 18,
Title = @"Senior Accountant"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 50,
HireDate = @"2007-11-18",
ID = 7,
Name = @"Pedro Rodriguez",
Phone = @"035-640230",
OnPTO = false,
ParentID = 10,
Title = @"Senior Localization Developer"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 27,
HireDate = @"2016-02-19",
ID = 8,
Name = @"Casey Harper",
Phone = @"0342-023176",
OnPTO = true,
ParentID = 10,
Title = @"Senior Localization"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 25,
HireDate = @"2017-11-09",
ID = 15,
Name = @"Patricia Simpson",
Phone = @"069-0245984",
OnPTO = false,
ParentID = 7,
Title = @"Localization Intern"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 39,
HireDate = @"2010-03-22",
ID = 9,
Name = @"Francisco Chang",
Phone = @"(91) 745 6200",
OnPTO = false,
ParentID = 7,
Title = @"Localization Intern"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 25,
HireDate = @"2018-03-18",
ID = 16,
Name = @"Peter Lewis",
Phone = @"069-0245984",
OnPTO = true,
ParentID = 7,
Title = @"Localization Intern"
});
}
}
csusing System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using IgniteUI.Blazor.Controls; // for registering Ignite UI modules
namespace Infragistics.Samples
{
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
// registering Ignite UI modules
builder.Services.AddIgniteUIBlazor(
typeof(IgbInputModule),
typeof(IgbTreeGridModule)
);
await builder.Build().RunAsync();
}
}
}
cs
@using IgniteUI.Blazor.Controls
@inject IJSRuntime JS
<div class="container vertical ig-typography">
<div class="container vertical fill">
<IgbTreeGrid
AutoGenerate="false"
Name="treeGrid"
@ref="treeGrid"
Data="EmployeesNestedTreeData"
RowEditable="true"
PrimaryKey="ID"
ForeignKey="ParentID"
CellSelection="GridSelectionMode.None"
Pinning="PinningConfig1">
<IgbColumn
Width="150px"
Filterable="false"
Pinned="true"
BodyTemplateScript="WebTreeGridRowPinCellTemplate"
Name="column1"
@ref="column1">
</IgbColumn>
<IgbColumn
Field="Name"
Header="Full Name">
</IgbColumn>
<IgbColumn
Field="Age"
DataType="GridColumnDataType.Number">
</IgbColumn>
<IgbColumn
Field="Title">
</IgbColumn>
<IgbColumn
Field="HireDate"
DataType="GridColumnDataType.Date">
</IgbColumn>
</IgbTreeGrid>
</div>
</div>
@code {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
var treeGrid = this.treeGrid;
var column1 = this.column1;
}
private IgbTreeGrid treeGrid;
private IgbPinningConfig _pinningConfig1 = null;
public IgbPinningConfig PinningConfig1
{
get
{
if (this._pinningConfig1 == null)
{
var pinningConfig1 = new IgbPinningConfig();
pinningConfig1.Rows = RowPinningPosition.Top;
this._pinningConfig1 = pinningConfig1;
}
return this._pinningConfig1;
}
}
private IgbColumn column1;
private EmployeesNestedTreeData _employeesNestedTreeData = null;
public EmployeesNestedTreeData EmployeesNestedTreeData
{
get
{
if (_employeesNestedTreeData == null)
{
_employeesNestedTreeData = new EmployeesNestedTreeData();
}
return _employeesNestedTreeData;
}
}
}
razor
igRegisterScript("WebTreeGridRowPinCellTemplate", (ctx) => {
var html = window.igTemplating.html;
window.toggleRowPin = function toggleRowPin(index) {
var treeGrid = document.getElementsByTagName("igc-tree-grid")[0];
treeGrid.getRowByIndex(index).pinned = !treeGrid.getRowByIndex(index).pinned;
}
const index = ctx.cell.id.rowIndex;
return html`<div>
<span onpointerdown='toggleRowPin("${index}")'>📌</span>
</div>`;
}, false);
js/*
CSS styles are loaded from the shared CSS file located at:
https://static.infragistics.com/xplatform/css/samples/
*/
css
行ピン固定の制限
- データソースに存在するレコードのみをピン固定できます。
- 行のピン固定状態は Excel にエクスポートされません。グリッドは行のピン固定が適用されずにエクスポートされます。
- グリッドのスクロール可能領域におけるピン固定行のコピーは、ピン固定行が存在する状態で他のグリッド機能が動作するのに不可欠な役割を果たします。そのため、その生成を無効化または削除することはできません。
- 行選択 は 行 ID のみで動作するため、ピン固定行を選択するとそのコピーも選択されます (逆も同様)。さらに、ピン固定領域での範囲選択 (Shift + クリックにより) は、スクロール可能な領域で行を範囲選択する場合と同じように機能します。結果として、間にある行はピン固定されていなくてもすべて選択されます。API を 介して選択した行を取得すると、選択した各レコードの単一のインスタンスのみを返します。
スタイル設定
定義済みのテーマに加えて、利用可能な CSS プロパティのいくつかを設定することで、グリッドをさらにカスタマイズできます。 一部の色を変更したい場合は、最初にグリッドのクラスを設定する必要があります。
<IgbTreeGrid class="grid"></IgbTreeGrid>
razor
次に、そのクラスに関連する CSS プロパティを設定します。
.grid {
--ig-grid-pinned-border-width: 5px;
--ig-grid-pinned-border-style: double;
--ig-grid-pinned-border-color: #FFCD0F;
--ig-grid-cell-active-border-color: #FFCD0F;
}
css
デモ
using System;
using System.Collections.Generic;
public class EmployeesNestedTreeDataItem
{
public double Age { get; set; }
public string HireDate { get; set; }
public double ID { get; set; }
public string Name { get; set; }
public string Phone { get; set; }
public bool OnPTO { get; set; }
public double ParentID { get; set; }
public string Title { get; set; }
}
public class EmployeesNestedTreeData
: List<EmployeesNestedTreeDataItem>
{
public EmployeesNestedTreeData()
{
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 55,
HireDate = @"2008-03-20",
ID = 1,
Name = @"Johnathan Winchester",
Phone = @"0251-031259",
OnPTO = false,
ParentID = -1,
Title = @"Development Manager"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 42,
HireDate = @"2014-01-22",
ID = 4,
Name = @"Ana Sanders",
Phone = @"(21) 555-0091",
OnPTO = true,
ParentID = -1,
Title = @"CEO"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 49,
HireDate = @"2014-01-22",
ID = 18,
Name = @"Victoria Lincoln",
Phone = @"(071) 23 67 22 20",
OnPTO = true,
ParentID = -1,
Title = @"Accounting Manager"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 61,
HireDate = @"2010-01-01",
ID = 10,
Name = @"Yang Wang",
Phone = @"(21) 555-0091",
OnPTO = false,
ParentID = -1,
Title = @"Localization Manager"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 43,
HireDate = @"2011-06-03",
ID = 3,
Name = @"Michael Burke",
Phone = @"0452-076545",
OnPTO = true,
ParentID = 1,
Title = @"Senior Software Developer"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 29,
HireDate = @"2009-06-19",
ID = 2,
Name = @"Thomas Anderson",
Phone = @"(14) 555-8122",
OnPTO = false,
ParentID = 1,
Title = @"Senior Software Developer"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 31,
HireDate = @"2014-08-18",
ID = 11,
Name = @"Monica Reyes",
Phone = @"7675-3425",
OnPTO = false,
ParentID = 1,
Title = @"Software Development Team Lead"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 35,
HireDate = @"2015-09-17",
ID = 6,
Name = @"Roland Mendel",
Phone = @"(505) 555-5939",
OnPTO = false,
ParentID = 11,
Title = @"Senior Software Developer"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 44,
HireDate = @"2009-10-11",
ID = 12,
Name = @"Sven Cooper",
Phone = @"0695-34 67 21",
OnPTO = true,
ParentID = 11,
Title = @"Senior Software Developer"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 44,
HireDate = @"2014-04-04",
ID = 14,
Name = @"Laurence Johnson",
Phone = @"981-443655",
OnPTO = false,
ParentID = 4,
Title = @"Director"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 25,
HireDate = @"2017-11-09",
ID = 5,
Name = @"Elizabeth Richards",
Phone = @"(2) 283-2951",
OnPTO = true,
ParentID = 4,
Title = @"Vice President"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 39,
HireDate = @"2010-03-22",
ID = 13,
Name = @"Trevor Ashworth",
Phone = @"981-443655",
OnPTO = true,
ParentID = 5,
Title = @"Director"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 44,
HireDate = @"2014-04-04",
ID = 17,
Name = @"Antonio Moreno",
Phone = @"(505) 555-5939",
OnPTO = false,
ParentID = 18,
Title = @"Senior Accountant"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 50,
HireDate = @"2007-11-18",
ID = 7,
Name = @"Pedro Rodriguez",
Phone = @"035-640230",
OnPTO = false,
ParentID = 10,
Title = @"Senior Localization Developer"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 27,
HireDate = @"2016-02-19",
ID = 8,
Name = @"Casey Harper",
Phone = @"0342-023176",
OnPTO = true,
ParentID = 10,
Title = @"Senior Localization"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 25,
HireDate = @"2017-11-09",
ID = 15,
Name = @"Patricia Simpson",
Phone = @"069-0245984",
OnPTO = false,
ParentID = 7,
Title = @"Localization Intern"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 39,
HireDate = @"2010-03-22",
ID = 9,
Name = @"Francisco Chang",
Phone = @"(91) 745 6200",
OnPTO = false,
ParentID = 7,
Title = @"Localization Intern"
});
this.Add(new EmployeesNestedTreeDataItem()
{
Age = 25,
HireDate = @"2018-03-18",
ID = 16,
Name = @"Peter Lewis",
Phone = @"069-0245984",
OnPTO = true,
ParentID = 7,
Title = @"Localization Intern"
});
}
}
csusing System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using IgniteUI.Blazor.Controls; // for registering Ignite UI modules
namespace Infragistics.Samples
{
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
// registering Ignite UI modules
builder.Services.AddIgniteUIBlazor(
typeof(IgbInputModule),
typeof(IgbTreeGridModule),
typeof(IgbActionStripModule)
);
await builder.Build().RunAsync();
}
}
}
cs
@using IgniteUI.Blazor.Controls
@inject IJSRuntime JS
<style>
/*
CSS styles are loaded from the shared CSS file located at:
https://static.infragistics.com/xplatform/css/samples/
*/
#treeGrid {
--ig-grid-pinned-border-width: 5px;
--ig-grid-pinned-border-style: double;
--ig-grid-pinned-border-color: #FFCD0F;
--ig-grid-cell-active-border-color: #FFCD0F;
}
</style>
<div class="container vertical ig-typography">
<div class="container vertical fill">
<IgbTreeGrid
AutoGenerate="false"
Id="treeGrid"
Name="treeGrid"
@ref="treeGrid"
Data="EmployeesNestedTreeData"
RenderedScript="WebTreeGridPinRowOnRendered"
RowEditable="true"
PrimaryKey="ID"
ForeignKey="ParentID"
CellSelection="GridSelectionMode.None"
Pinning="PinningConfig1">
<IgbColumn
Field="Name"
Header="Full Name">
</IgbColumn>
<IgbColumn
Field="Age"
DataType="GridColumnDataType.Number">
</IgbColumn>
<IgbColumn
Field="Title">
</IgbColumn>
<IgbColumn
Field="HireDate"
DataType="GridColumnDataType.Date">
</IgbColumn>
<IgbActionStrip
Name="actionStrip"
@ref="actionStrip">
<IgbGridPinningActions
>
</IgbGridPinningActions>
</IgbActionStrip>
</IgbTreeGrid>
</div>
</div>
@code {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
var treeGrid = this.treeGrid;
var actionStrip = this.actionStrip;
}
private IgbTreeGrid treeGrid;
private IgbPinningConfig _pinningConfig1 = null;
public IgbPinningConfig PinningConfig1
{
get
{
if (this._pinningConfig1 == null)
{
var pinningConfig1 = new IgbPinningConfig();
pinningConfig1.Rows = RowPinningPosition.Top;
this._pinningConfig1 = pinningConfig1;
}
return this._pinningConfig1;
}
}
private IgbActionStrip actionStrip;
private EmployeesNestedTreeData _employeesNestedTreeData = null;
public EmployeesNestedTreeData EmployeesNestedTreeData
{
get
{
if (_employeesNestedTreeData == null)
{
_employeesNestedTreeData = new EmployeesNestedTreeData();
}
return _employeesNestedTreeData;
}
}
}
razor
igRegisterScript("WebTreeGridPinRowOnRendered", (event) => {
var treeGrid = document.getElementById("treeGrid") || document.getElementById("grid");
treeGrid.data = [...treeGrid.data];
treeGrid.pinRow(1);
treeGrid.pinRow(11);
}, false);
js/*
CSS styles are loaded from the shared CSS file located at:
https://static.infragistics.com/xplatform/css/samples/
*/
#treeGrid {
--ig-grid-pinned-border-width: 5px;
--ig-grid-pinned-border-style: double;
--ig-grid-pinned-border-color: #FFCD0F;
--ig-grid-cell-active-border-color: #FFCD0F;
}
css
API リファレンス
IgbTreeGrid
TreeGridRow
IgbRowType
その他のリソース
コミュニティに参加して新しいアイデアをご提案ください。