<EjsGrid DataSource="@Orders" @ref="Grid" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" Height="315">
<GridEvents OnActionBegin="Begin" OnActionComplete="Complete" TValue="Order"></GridEvents>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Dialog"></GridEditSettings>
<GridColumns>
. . . . .. . . . . .
<GridColumn Field=@nameof(Order.ShipCountry) HeaderText="Ship Country" EditType="EditType.DropDownEdit" Visible="false" Width="150"></GridColumn>
</GridColumns>
</EjsGrid>
@code{
EjsGrid<Order> Grid;
public List<Order> Orders { get; set; }
public async void Begin(ActionEventArgs<Order> Args)
{
if(Args.RequestType == Syncfusion.EJ2.Blazor.Grids.Action.BeginEdit || Args.RequestType == Syncfusion.EJ2.Blazor.Grids.Action.Add)
{
await Grid.ShowColumns("Ship Country");
}
}
public async void Complete(ActionEventArgs<Order> Args)
{
if(Args.RequestType == Syncfusion.EJ2.Blazor.Grids.Action.BeginEdit || Args.RequestType == Syncfusion.EJ2.Blazor.Grids.Action.Add)
{
await Grid.HideColumns("Ship Country");
}
}
. . . .. . . . .
}
|
List<string> Cols = new List<string>() { "Ship Country", "Freight" }; // list of HeaderText of the grid Column
await Grid.HideColumns(Cols); |
<GridColumn Field=@nameof(Order.ShipCountry) HeaderText="Ship Country" EditType="EditType.DropDownEdit" Width="0"></GridColumn>
|