Remove Command Columns for Specific Rows

Hi,


I want to remove the "Edit" command column for specific rows. How do I do this?

Here is a picture for reference.



Thank you,

Kenney


3 Replies

RS Renjith Singh Rajendran Syncfusion Team September 17, 2021 10:34 AM UTC

Hi Kenney,  

Greetings from Syncfusion support.  

We suggest you to bind the RowDataBound event to Grid and assign custom class to Grid’s row based on your scenario inside this event handler. Now based on this added class hide the command button. We have prepared a sample based on this scenario, in which we have hidden the edit button based on the “ShowCommand” field value.  
References :  

Please refer the codes below, 

<GridEvents RowDataBound="RowDataBoundHandler" TValue="Order"></GridEvents>
 
<GridColumn HeaderText="Manage Records" Width="150"> 
    <GridCommandColumns> 
        <GridCommandColumn Type="CommandButtonType.Edit" ButtonOption="@(new CommandButtonOptions() { IconCss = "e-icons e-edit" 
        CssClass = "e-flat editcommand" })"></GridCommandColumn> 
        ... 
    </GridCommandColumns> 
 </GridColumn> 

<style>    .e-disablecommand .e-rowcell.e-unboundcell .e-unboundcelldiv .editcommand {        display:none;    }</style>
public void RowDataBoundHandler(RowDataBoundEventArgs<Order> Args){    if (!Args.Data.ShowCommand)    {        Args.Row.AddClass(new string[] { "e-disablecommand" });    }}

Please get back to us if you have further queries.   

Regards, 
Renjith R 



RC Rogerio C Mauri April 7, 2023 02:25 PM UTC

Consider that I have several command buttons of type 'CommandButtonType.None' and I want to suppress some according to a record condition.


How could I implement this?



MS Monisha Saravanan Syncfusion Team April 10, 2023 12:46 PM UTC


Hi Rogerio,


Greetings from Syncfusion.


We have prepared an simple sample by using  several command columns with CommandButtonType.None and we have suppressed some buttons based on the status column. Kindly check the attached sample for your reference.


<GridColumn HeaderText="Manage Records" Width="450">

            <GridCommandColumns>

 

                <GridCommandColumn Type="CommandButtonType.None" ButtonOption="@(new CommandButtonOptions() { Content="ViewResults" })"></GridCommandColumn>

                <GridCommandColumn Type="CommandButtonType.None" ButtonOption="@(new CommandButtonOptions() {  Content="Delete"})"></GridCommandColumn>

 

                <GridCommandColumn Type="CommandButtonType.None" ButtonOption="@(new CommandButtonOptions() { Content="Cancel", CssClass="e-cancel" })"></GridCommandColumn>

                <GridCommandColumn Type="CommandButtonType.None" ButtonOption="@(new CommandButtonOptions() { Content="Copy",CssClass = "e-update" })"></GridCommandColumn>

                <GridCommandColumn Type="CommandButtonType.None" ButtonOption="@(new CommandButtonOptions() {  Content="View and Edit", CssClass="e-vieww" })"></GridCommandColumn>

 

 

 

            </GridCommandColumns>


Please let us know if you have any concerns.


Regards,

Monisha


Attachment: BlazorApp1_291c3ef.zip

Loader.
Up arrow icon