Example 1
<SfGrid DataSource="@Orders" AllowPaging="true" Height="315">
<GridEvents RowDataBound="RowBound" TValue="Order"></GridEvents>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>
<GridColumns>
. . . . . .
<GridColumn HeaderText="Manage Records" Width="150">
. . . . . . . .
</GridColumn>
</GridColumns>
</SfGrid>
<style>
.e-removecommand .e-unboundcell .e-unboundcelldiv button {
display: none;
}
</style>
@code{
public List<Order> Orders { get; set; }
public void RowBound(RowDataBoundEventArgs<Order> Args)
{
if (Args.Data.Verified)
{
Args.Row.AddClass(new string[] { "e-removecommand" });
}
}
Example 2
<GridEvents RowDataBound="OnRowBound"></GridEvents>
<GridColumn HeaderText="Manage" TextAlign="TextAlign.Center" Width="100">
<GridCommandColumns>
<GridCommandColumn Type="CommandButtonType.Edit" ButtonOption="@(new CommandButtonOptions() { IconCss = "e-icons e-edit", CssClass = "e-flat" })"></GridCommandColumn>
<GridCommandColumn Type="CommandButtonType.Delete" ButtonOption="@(new CommandButtonOptions() { IconCss = "e-icons e-delete", CssClass = "e-flat" })"></GridCommandColumn>
</GridCommandColumns>
</GridColumn>
<style>
.e-removecommand .e-unboundcell .e-unboundcelldiv button {
display: none;
}
</style>
public void OnRowBound(RowDataBoundEventArgs<Order> Args)
{
if (Args.Data.TypeId != 1)
{
Args.Row.AddClass(new string[] { "e-removecommand" });
}
}
Sources:
https://www.syncfusion.com/forums/155584/i-would-like-to-show-hide-gridcommandcolumn-base-on-the-row-data
Comments