Conditionally hide a single button in GridCommandColumn

I have 3 Command Buttons in my grid, but I would only like one of the buttons to appear on a value in the record being set to true. This is my Grid Column.

  <GridColumn HeaderText="Options">

            <GridCommandColumns>

                <GridCommandColumn Type="CommandButtonType.None" ButtonOption="@(new CommandButtonOptions() {IconCss="fa-solid fa-clock-rotate-left", CssClass="e-flat grid-delete-btn"})" Title="Reset Rates" ID="btnReset" />

                <GridCommandColumn Type="CommandButtonType.None" ButtonOption="@(new CommandButtonOptions() {IconCss="fa-regular fa-clock", CssClass="e-flat grid-add-btn"})" Title="Edit Hours" ID="edtHours" />

                <GridCommandColumn Type="CommandButtonType.None" ButtonOption="@(new CommandButtonOptions() {IconCss="fa-solid fa-sterling-sign", CssClass="e-flat grid-edit-btn"})" Title="Edit Rates" ID="edtRate" />

            </GridCommandColumns>

        </GridColumn>

I know I can do this if I split the commands into separate columns, but I really don't want to do that, I also tried the RowDataBound method, but that removes all the buttons and not just a single one, any ideas on this ?


1 Reply

KG Keerthana Ganesan Syncfusion Team September 26, 2022 03:59 PM UTC

Hi Simon,

Greetings from Syncfusion support.

Query: Conditionally hide a single button in the GridCommand column.


We have analyzed your query and we suggest you hide the command column button by using the RowDataBound event as per documentation to overcome the issue Kindly refer to the attached document link for your reference.


If you are still facing any issues kindly share the entire grid code and issue a reproducible sample, it will be help full to validate further at our end and provide a solution as early as possible.

Reference link: https://blazor.syncfusion.com/documentation/datagrid/how-to/hide-command-column-based-on-record-detail

Regards,

Keerthana.


Loader.
Up arrow icon