<EjsGrid @ref="gridInstance" AllowSelection="true" DataSource="@Orders" Height="315">
<GridEvents OnDataBound="DataBoundHandler" TValue="Order"></GridEvents>
...
</EjsGrid>
public async void DataBoundHandler(BeforeDataBoundArgs<Order> args)
{
await Task.Delay(200);
string myDynamicJSON = "[{rowIndex: 0, cellIndexes:[1]},{rowIndex: 2, cellIndexes:[2,3]}]";
this.gridInstance.SelectCells((IEnumerable<object>)JsonConvert.DeserializeObject(myDynamicJSON));
}
|
<EjsGrid AllowSelection="true" ...>
<GridEvents OnLoad="OnLoad" RowSelected="RowSelected" TValue="Order"></GridEvents>
...
</EjsGrid>
@code{
...
public bool flag = false;
public void OnLoad()
{
this.flag = true;
}
public void RowSelected(RowSelectEventArgs<Order> args)
{
if (this.flag)
{
//perform actions during initial load selection
this.flag = false;
}
else
{
//perform actions after loading during manual selection
}
}
...
}
|
<EjsGrid @ref="GridInstance" AllowSelection="true" AllowPaging="true" DataSource="@Orders" Height="315">
<GridEvents OnDataBound="DataBoundHandler" TValue="Order"></GridEvents>
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Multiple"></GridSelectionSettings> @*By default the selection Mode will be Row*@
...
</EjsGrid>
@code{
...
public async void DataBoundHandler(BeforeDataBoundArgs<Order> args)
{
await Task.Delay(200);
this.GridInstance.GoToPage(2);
this.GridInstance.SelectRow(4);
}
...
} |
public async void DataBoundHandler(BeforeDataBoundArgs<Order> args)
{
await Task.Delay(200);
var PrimayIndex = await this.GridInstance.GetRowIndexByPrimaryKey(1006); //Based on primarykey value fetch index
this.GridInstance.SelectRow(PrimayIndex); //Use the index to select row
}
|
public async void click() //As an example, we have used the button click to call GetSelectedRecords method
{
var SelectedRecords = await this.gridInstance.GetSelectedRecords(); //Fetch the selected records
var FirstRowPrimaryValue = SelectedRecords[0].OrderID; //Here you can fetch the primary key value of your selected row.
}
|