|
<SfGrid @ref="Grid" DataSource="@Orders" AllowSelection="true" AllowPaging="true">
<GridEvents RowSelecting="OnRowSelecting" TValue="Order"></GridEvents>
<GridSelectionSettings Type="SelectionType.Multiple" CheckboxOnly="true"></GridSelectionSettings>
<GridColumns>
<GridColumn Type="ColumnType.CheckBox" HeaderText="Select" Width="50"></GridColumn>
. . .
</GridColumns>
</SfGrid>
@code{
public async Task OnRowSelecting(RowSelectingEventArgs<Order> args)
{
var records = await this.Grid.GetSelectedRecords();
if(records.Count > 3) // Will Cancel the Selection more than 4 records
{
args.Cancel = true;
// You can render Alert here
}
}
} |
|
<SfGrid @ref="Grid" DataSource="@Orders" AllowSelection="true" AllowPaging="true">
<GridEvents QueryCellInfo="QueryCellInfo" TValue="Order"></GridEvents>
<GridSelectionSettings Type="SelectionType.Multiple" CheckboxOnly="true"></GridSelectionSettings>
<GridColumns>
<GridColumn Type="ColumnType.CheckBox" HeaderText="Select" Width="50"></GridColumn>
. . .
</GridColumns>
</SfGrid>
<style>
.e-rowcell.e-attr,
.e-headercelldiv.e-headerchkcelldiv {
pointer-events:none;
}
.e-rowcell.e-attr .e-icons,
.e-headerchkcelldiv .e-icons{
opacity:0.5;
}
</style>
@code{
public void QueryCellInfo(QueryCellInfoEventArgs<Order> args)
{
if(args.Column.HeaderText == "Select" && args.Data.OrderID < 1003 )
{
args.Cell.AddClass(new string[] { "e-attr"});
}
}
} |
|
<head>
<link rel='nofollow' href="_content/Syncfusion.Blazor/styles/bootstrap4.css" rel="stylesheet" />
</head> |
|
<SfGrid @ref="Grid" DataSource="@Orders" AllowPaging="true">
<GridEvents DataBound="Data" TValue="Order"></GridEvents>
<GridColumns>
<GridColumn Type="ColumnType.CheckBox" Width="120"></GridColumn>
</SfGrid>
@code{
SfGrid<Order> Grid;
public List<Order> Orders { get; set; }
List<int> Indexes = new List<int>();
public void Data(object args)
{
var Source = this.Grid.DataSource;
var IndexNum = 0;
foreach (var Data in Source)
{
if (Data.Verified == true)
{
Indexes.Add(IndexNum);
}
IndexNum++;
}
Grid.SelectRows(Indexes);
}
} |