DxGridCommandColumn elements visibility handled programmatically in DxGrid

22 views Asked by At

I'm using the DxGrid component for a razor page in a Blazor Webassembly project. Having the following declaration in the DxGrid component:

            <Columns>
                <DxGridDataColumn FieldName="column1" />
                <DxGridDataColumn FieldName="column2" />
                <DxGridDataColumn FieldName="column3" />
                <DxGridCommandColumn Width="160px" DeleteButtonVisible="false" />
            </Columns>

the rendered grid will have 4 column with the last one having the Add, Edit functions, the Delete is hidden because of the DeleteButtonVisible="false". But is there a way to hide that Delete in function of the value of the property for a specific row?

1

There are 1 answers

0
andreasperelli On

Solved in this way:

            <DxGridCommandColumn>
                <HeaderTemplate>
                    <a class="oi oi-plus" @onclick="@(() => MyGrid.StartEditNewRowAsync())" style="text-decoration: none;" href="javascript:void(0);">New</a>
                </HeaderTemplate>
                <CellDisplayTemplate>
                        <a class="oi oi-pencil" @onclick="@(() => MyGrid.StartEditRowAsync(context.VisibleIndex))" style="text-decoration: none;" href="javascript:void(0);">Edit</a>
                    <span> </span>
                    @if (context.GetRowValue("Column1").Equals("Example"))
                    {
                    <a class="oi oi-x" @onclick="@(() => MyGrid.ShowDataItemDeleteConfirmation(context.DataItem))" style="text-decoration: none;" href="javascript:void(0);">Delete</a>
                     }
                </CellDisplayTemplate>
            </DxGridCommandColumn>