IgbGrid の CellClick イベントコールバック プロパティでクリックされたセルの行 ID や行データを取得したい場合、まず行 ID については引数として渡されてくる IgbGridCellEventArgs クラス オブジェクトの Detail -> Cell -> Id -> RowID で取得できます。次に行データについては IgbGrid の参照が IgbGridCellEventArgs クラス オブジェクトの Parent プロパティで取得できますので、あとは IgbGrid の GetRowByKeyAsync メソッドに行 ID を渡して呼び出してください。
<IgbGrid ...
Data="People" PrimaryKey="ID"
CellClick="((e) => OnCellClickedAsync(e))"
... />
@code {
private IEnumerable<Person>? People;
private Person? ClickedPerson = null;
private async Task OnCellClickedAsync(IgbGridCellEventArgs e)
{
// RowIDはString型です。
// 適宜、バインドしているクラスの定義に従ってキャストをしてください。
var rowID = e.Detail.Cell.Id.RowID;
var igbGrid = e.Parent as IgbGrid;
if (igbGrid == null) return;
var rowType = await igbGrid.GetRowByKeyAsync(rowID);
this.ClickedPerson = rowType.Data as Person;
}
}
実行結果
